home *** CD-ROM | disk | FTP | other *** search
/ Complete RPG Maker XP - 41 Games / tg esp 48 rpg maker.iso / Essenciais / AdbeRdr707_en_US_distrib.exe / Data1.cab / bootstrap.js < prev    next >
Encoding:
JavaScript  |  2005-11-28  |  130.1 KB  |  3,791 lines

  1. // ==========================================================================
  2. //    Module: MasterScript.js
  3. // ==========================================================================
  4. //    JS functionality for Updater
  5. // ==========================================================================
  6. //  The Software, including this file, is subject to the End User License 
  7. //  Agreement.
  8. //  Copyright (c) 2003-2004, Adobe Systems Incorporated, All Rights Reserved.
  9. // ==========================================================================
  10.  
  11. //
  12. // All scripts (master, data, code, ui, maintainance, etc) should obey the
  13. // following conventions:
  14. //
  15. // -- each script can define one and only one object.  eval() returns the
  16. // result of evaluating the last statement of the script.  therefore, the
  17. // last statement of all script should simply be the script obj.
  18. // 
  19. // -- has a "version" key
  20. // 
  21. // --  more to be added
  22.  
  23. // constants used during evaluation for dialog descriptions
  24. var isMac = new Boolean(updater.app.platform.substr(0,3) == "MAC");
  25. var isWin = new Boolean(updater.app.platform.substr(0,3) == "WIN");
  26. var isReader = new Boolean((updater.app.viewerType.substr(0,6) == "Reader"));
  27.  
  28. var nextCheckText = (updater.app.getUpdaterString("IDS_PREFS_PANEL_NEXTCHECK"));
  29. var manualNextCheck = (updater.app.getUpdaterString("IDS_PREFS_PANEL_MANUALNEXTCHECK"));
  30. var checkForUpdatesText = (updater.app.getUpdaterString("IDS_PREFS_PANEL_CHECKTXT"));
  31. var updateAcrobatNowText = (updater.app.getUpdaterString("IDS_UPDATE_ACROBAT_NOW"));
  32. var updateReaderNowText = (updater.app.getUpdaterString("IDS_UPDATE_READER_NOW"));
  33. var updateNotificationBtn = (updater.app.getUpdaterString("IDS_PREFS_PANEL_VIEW_NOTIFS"));
  34. var displayStartupNotifDlgText = (updater.app.getUpdaterString("IDS_UPDATE_SHOW_NOTIF_TXT"));
  35. var showInstallCompDlgText = (updater.app.getUpdaterString("IDS_UPDATE_SHOW_INSTCOMP_TXT"));
  36. var autoBkgrndMethodText = (updater.app.getUpdaterString("IDS_PREFS_PANEL_UPDATEINBACKGROUND"));
  37. var autoForegrndMethodText = (updater.app.getUpdaterString("IDS_PREFS_PANEL_UPDATEMONTHLY"));
  38.  
  39. // calcuate width of the button 
  40. var gStaticTextWidth = 8;
  41. //var gUpdateNowWidth =  (gStaticTextWidth * Math.max(updateAcrobatNowText.length, updateReaderNowText.length));
  42. var gUpdateNowWidth = (gStaticTextWidth * updateNotificationBtn.length);
  43.  
  44. var ScriptObj = {
  45.  
  46.     version:"1.40",
  47.     
  48.     msUDStateUnknown: 0,
  49.     msUDStateAutoUD: 1,
  50.     msUDStateManualUD: 2,
  51.     msUDStateFindComp: 3,
  52.     msUDStateCheckForUD: 4,
  53.     msUDStateNewPDF: 5,
  54.  
  55.     msAVAcrobatRegionInternational: 0,
  56.     msAVAcrobatRegionCentralEurope: 1,
  57.     msAVAcrobatRegionMiddleEast: 2,
  58.  
  59.     // Localized JS strings needed by the Pref Panel -- copy these directly from ResourceScript.js files.
  60.     // Don't put these in ResourceScript.js because the user may see the pref panel without having 
  61.     // any scripts downloaded.
  62.     // Not being used currently (used to have Installed Updates button text that got added between 6.0 and 
  63.     // 6.0.1)
  64.     PrefPanelLocJSStrings:
  65.     {
  66.         "ENU" :
  67.         {
  68.             "IDS_UDWEEKLYDESCTEXT_ACRO" : "Adobe Acrobat can automatically check for critical updates and notifications once a week. If you disable this feature, you can manually check for updates by choosing Help > Check for updates now...",
  69.             "IDS_UDWEEKLYDESCTEXT_RDR" : "Adobe Reader can automatically check for critical updates and notifications once a week. If you disable this feature, you can manually check for updates by choosing Help > Check for updates now..."
  70.         },
  71.         "CHS" :
  72.         {
  73.             "IDS_UDWEEKLYDESCTEXT_ACRO" : "Adobe Acrobat \u53EF\u4EE5\u6BCF\u6708\u81EA\u52A8\u68C0\u67E5\u5173\u952E\u7684\u66F4\u65B0\u5E76\u8FDB\u884C\u901A\u77E5\u3002\u5982\u679C\u505C\u7528\u672C\u529F\u80FD\uFF0C\u60A8\u53EF\u4EE5\u9009\u62E9\u201C\u5E2E\u52A9\u201D>\u201C\u73B0\u5728\u68C0\u67E5"
  74.                             + "\u66F4\u65B0...\u201D\u6765\u624B\u52A8\u68C0\u67E5\u66F4\u65B0\u3002",
  75.             "IDS_UDWEEKLYDESCTEXT_RDR" : "Adobe Reader \u53EF\u4EE5\u6BCF\u6708\u81EA\u52A8\u68C0\u67E5\u5173\u952E\u7684\u66F4\u65B0\u5E76\u8FDB\u884C\u901A\u77E5\u3002\u5982\u679C\u505C\u7528\u672C\u529F\u80FD\uFF0C\u60A8\u53EF\u4EE5\u9009\u62E9\u201C\u5E2E\u52A9\u201D>\u201C\u73B0\u5728\u68C0\u67E5"
  76.                             + "\u66F4\u65B0...\u201D\u6765\u624B\u52A8\u68C0\u67E5\u66F4\u65B0\u3002"
  77.         },
  78.         "CHT" :
  79.         {
  80.             "IDS_UDWEEKLYDESCTEXT_ACRO" : "Adobe Acrobat \u53EF\u4EE5\u6BCF\u9031\u81EA\u52D5\u6AA2\u67E5\u91CD\u8981\u7684\u66F4\u65B0\u4E26\u767C\u51FA\u901A\u77E5\u3002\u5982\u679C\u60A8\u505C\u7528\u6B64\u529F\u80FD\uFF0C\u60A8\u53EF\u4EE5\u9078\u64C7\u300C\u8AAA\u660E\u300D>\u300C\u73FE\u5728\u6AA2"
  81.                             + "\u67E5\u66F4\u65B0...\u300D\u4F86\u624B\u52D5\u6AA2\u67E5\u66F4\u65B0\u3002",
  82.             "IDS_UDWEEKLYDESCTEXT_RDR" : "Adobe Reader \u53EF\u4EE5\u6BCF\u9031\u81EA\u52D5\u6AA2\u67E5\u91CD\u8981\u7684\u66F4\u65B0\u4E26\u767C\u51FA\u901A\u77E5\u3002\u5982\u679C\u60A8\u505C\u7528\u6B64\u529F\u80FD\uFF0C\u60A8\u53EF\u4EE5\u9078\u64C7\u300C\u8AAA\u660E\u300D>\u300C\u73FE\u5728\u6AA2"
  83.                             + "\u67E5\u66F4\u65B0...\u300D\u4F86\u624B\u52D5\u6AA2\u67E5\u66F4\u65B0\u3002"
  84.         },
  85.         "DAN" :
  86.         {
  87.             "IDS_UDWEEKLYDESCTEXT_ACRO" : "Adobe Acrobat kan automatisk s\u00F8ge efter vigtige opdateringer og meddelelser en gang om ugen. Hvis du deaktiverer denne funktion, kan du manuelt kontrollere, om der er opdateringer, ved at v\u00E6lge Hj\u00E6lp > Kontroller for opdateringer nu...",
  88.             "IDS_UDWEEKLYDESCTEXT_RDR" : "Adobe Reader kan automatisk s\u00F8ge efter vigtige opdateringer og meddelelser en gang om ugen. Hvis du deaktiverer denne funktion, kan du manuelt kontrollere, om der er opdateringer, ved at v\u00E6lge Hj\u00E6lp > Kontroller for opdateringer nu..."
  89.         },
  90.         "DEU" :
  91.         {
  92.             "IDS_UDWEEKLYDESCTEXT_ACRO" : "Adobe Acrobat kann einmal w\u00F6chentlich automatisch pr\u00FCfen, ob wichtige Updates und Benachrichtigungen verf\u00FCgbar sind. Wenn Sie diese Funktion deaktivieren, k\u00F6nnen Sie manuell nach Updates suchen, indem Sie \x22Hilfe\x22 > \x22Jetzt nach U"
  93.                             + "pdates suchen\x22 w\u00E4hlen.",
  94.             "IDS_UDWEEKLYDESCTEXT_RDR" : "Adobe Reader kann einmal w\u00F6chentlich automatisch pr\u00FCfen, ob wichtige Updates und Benachrichtigungen verf\u00FCgbar sind. Wenn Sie diese Funktion deaktivieren, k\u00F6nnen Sie manuell nach Updates suchen, indem Sie \x22Hilfe\x22 > \x22Jetzt nach Up"
  95.                             + "dates suchen\x22 w\u00E4hlen."
  96.         },
  97.         "ESP" :
  98.         {
  99.             "IDS_UDWEEKLYDESCTEXT_ACRO" : "Adobe Acrobat puede comprobar autom\u00E1ticamente si hay notificaciones y actualizaciones importantes una vez a la semana. Si desactiva esta funci\u00F3n, podr\u00E1 comprobar manualmente si hay actualizaciones seleccionando Ayuda > Buscar actualizaciones "
  100.                             + "ahora...",
  101.             "IDS_UDWEEKLYDESCTEXT_RDR" : "Adobe Reader puede comprobar autom\u00E1ticamente si hay notificaciones y actualizaciones importantes una vez a la semana. Si desactiva esta funci\u00F3n, podr\u00E1 comprobar manualmente si hay actualizaciones seleccionando Ayuda > Buscar actualizaciones a"
  102.                             + "hora\u2026"
  103.         },
  104.         "FRA" :
  105.         {
  106.             "IDS_UDWEEKLYDESCTEXT_ACRO" : "Adobe Acrobat peut rechercher automatiquement les mises \u00E0 jour et notifications critiques une fois par semaine. Si vous d\u00E9sactivez cette fonction, vous pouvez rechercher les mises \u00E0 jour manuellement en s\u00E9lectionnant Aide > Rechercher le"
  107.                             + "s mises \u00E0 jour maintenant.",
  108.             "IDS_UDWEEKLYDESCTEXT_RDR" : "Adobe Reader peut rechercher automatiquement les mises \u00E0 jour et notifications critiques une fois par semaine. Si vous d\u00E9sactivez cette fonction, vous pouvez rechercher les mises \u00E0 jour manuellement en s\u00E9lectionnant Aide > Rechercher les"
  109.                             + " mises \u00E0 jour maintenant."
  110.         },
  111.         "ITA" :
  112.         {
  113.             "IDS_UDWEEKLYDESCTEXT_ACRO" : "Adobe Acrobat pu\u00F2 controllare automaticamente per aggiornamenti e notifiche una volta alla settimana. Se si disabilita questa funzione, \u00E8 possibile controllare manualmente per aggiornamenti scegliendo ? > Controlla aggiornamenti...",
  114.             "IDS_UDWEEKLYDESCTEXT_RDR" : "Adobe Reader pu\u00F2 controllare automaticamente per aggiornamenti e notifiche una volta alla settimana. Se si disabilita questa funzione, \u00E8 possibile controllare manualmente per aggiornamenti scegliendo ? > Controlla aggiornamenti..."
  115.         },
  116.         "JPN" :
  117.         {
  118.             "IDS_UDWEEKLYDESCTEXT_ACRO" : "Adobe Acrobat \u3067\u306F\u3001\u91CD\u8981\u306A\u30A2\u30C3\u30D7\u30C7\u30FC\u30C8\u3084\u901A\u77E5\u306E\u6709\u7121\u3092 1 \u9031\u9593\u306B\u4E00\u5EA6\u81EA\u52D5\u7684\u306B\u30C1\u30A7\u30C3\u30AF\u3059\u308B\u3053\u3068\u304C\u3067\u304D\u307E"
  119.                             + "\u3059\u3002\u3053\u306E\u6A5F\u80FD\u3092\u7121\u52B9\u306B\u3057\u305F\u5834\u5408\u3001\u30D8\u30EB\u30D7\u30E1\u30CB\u30E5\u30FC\u304B\u3089\u30A2\u30C3\u30D7\u30C7\u30FC\u30C8\u306E\u6709\u7121\u3092\u624B\u52D5\u3067\u30C1\u30A7\u30C3\u30AF\u3059\u308B"
  120.                             + "\u3053\u3068\u3082\u3067\u304D\u307E\u3059\u3002",
  121.             "IDS_UDWEEKLYDESCTEXT_RDR" : "Adobe Reader \u3067\u306F\u3001\u91CD\u8981\u306A\u30A2\u30C3\u30D7\u30C7\u30FC\u30C8\u3084\u901A\u77E5\u306E\u6709\u7121\u3092 1 \u9031\u9593\u306B\u4E00\u5EA6\u81EA\u52D5\u7684\u306B\u30C1\u30A7\u30C3\u30AF\u3059\u308B\u3053\u3068\u304C\u3067\u304D\u307E\u3059"
  122.                             + "\u3002\u3053\u306E\u6A5F\u80FD\u3092\u7121\u52B9\u306B\u3057\u305F\u5834\u5408\u3001\u30D8\u30EB\u30D7\u30E1\u30CB\u30E5\u30FC\u304B\u3089\u30A2\u30C3\u30D7\u30C7\u30FC\u30C8\u306E\u6709\u7121\u3092\u624B\u52D5\u3067\u30C1\u30A7\u30C3\u30AF\u3059\u308B\u3053"
  123.                             + "\u3068\u3082\u3067\u304D\u307E\u3059\u3002"
  124.         },
  125.         "KOR" :
  126.         {
  127.             "IDS_UDWEEKLYDESCTEXT_ACRO" : "Adobe Acrobat\uC5D0\uC11C \uC911\uC694\uD55C \uC5C5\uB370\uC774\uD2B8\uC640 \uC54C\uB9BC\uC744 \uD55C \uC8FC\uC5D0 \uD55C \uBC88\uC529 \uC790\uB3D9\uC73C\uB85C \uD655\uC778\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4. \uC774 \uAE30\uB2A5\uC744 \uC0AC\uC6A9\uD558\uC9C0"
  128.                             + " \uC54A\uC744 \uACBD\uC6B0, [\uB3C4\uC6C0\uB9D0] > [\uC9C0\uAE08 \uC5C5\uB370\uC774\uD2B8 \uD655\uC778...]\uC744 \uC120\uD0DD\uD558\uC5EC \uC218\uB3D9\uC73C\uB85C \uC5C5\uB370\uC774\uD2B8\uB97C \uD655\uC778\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.",
  129.             "IDS_UDWEEKLYDESCTEXT_RDR" : "Adobe Reader\uC5D0\uC11C \uC911\uC694\uD55C \uC5C5\uB370\uC774\uD2B8\uC640 \uC54C\uB9BC\uC744 \uD55C \uC8FC\uC5D0 \uD55C \uBC88\uC529 \uC790\uB3D9\uC73C\uB85C \uD655\uC778\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4. \uC774 \uAE30\uB2A5\uC744 \uC0AC\uC6A9\uD558\uC9C0"
  130.                             + " \uC54A\uC744 \uACBD\uC6B0, [\uB3C4\uC6C0\uB9D0] > [\uC9C0\uAE08 \uC5C5\uB370\uC774\uD2B8 \uD655\uC778...]\uC744 \uC120\uD0DD\uD558\uC5EC \uC218\uB3D9\uC73C\uB85C \uC5C5\uB370\uC774\uD2B8\uB97C \uD655\uC778\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4."
  131.         },
  132.         "NLD" :
  133.         {
  134.             "IDS_UDWEEKLYDESCTEXT_ACRO" : "Adobe Acrobat kan automatisch een keer in de week controleren op kritieke updates en berichten. Als u deze functie uitschakelt, kunt u handmatig controleren op updates door Help > Nu controleren op updates... te kiezen.",
  135.             "IDS_UDWEEKLYDESCTEXT_RDR" : "Adobe Reader kan automatisch een keer in de week controleren op kritieke updates en berichten. Als u deze functie uitschakelt, kunt u handmatig controleren op updates door Help > Nu controleren op updates... te kiezen."
  136.         },
  137.         "NOR" :
  138.         {
  139.             "IDS_UDWEEKLYDESCTEXT_ACRO" : "Adobe Acrobat kan automatisk se etter kritiske oppdateringer og kunngj\u00F8ringer en gang i uken. Hvis du deaktiverer denne funksjonen, kan du se etter oppdateringer manuelt ved \u00E5 velge Hjelp > Se etter oppdateringer n\u00E5...",
  140.             "IDS_UDWEEKLYDESCTEXT_RDR" : "Adobe Reader kan automatisk se etter kritiske oppdateringer og kunngj\u00F8ringer en gang i uken. Hvis du deaktiverer denne funksjonen, kan du se etter oppdateringer manuelt ved \u00E5 velge Hjelp > Se etter oppdateringer n\u00E5..."
  141.         },
  142.         "PTB" :
  143.         {
  144.             "IDS_UDWEEKLYDESCTEXT_ACRO" : "Uma vez por semana, o Adobe Acrobat pode verificar automaticamente se h\u00E1 atualiza\u00E7\u00F5es cr\u00EDticas e notifica\u00E7\u00F5es. Se voc\u00EA desativar esse recurso, verifique manualmente as atualiza\u00E7\u00F5es escolhendo Ajuda > Verificar at"
  145.                             + "ualiza\u00E7\u00F5es agora...",
  146.             "IDS_UDWEEKLYDESCTEXT_RDR" : "Uma vez por semana, o Adobe Reader pode verificar automaticamente se h\u00E1 atualiza\u00E7\u00F5es cr\u00EDticas e notifica\u00E7\u00F5es. Se voc\u00EA desativar esse recurso, verifique manualmente as atualiza\u00E7\u00F5es escolhendo Ajuda > Verificar atu"
  147.                             + "aliza\u00E7\u00F5es agora..."
  148.         },
  149.         "SUO" :
  150.         {
  151.             "IDS_UDWEEKLYDESCTEXT_ACRO" : "Adobe Acrobat voi tarkistaa automaattisesti kerran viikossa, onko t\u00E4rkeit\u00E4 p\u00E4ivityksi\u00E4 tai ilmoituksia saatavana. Jos poistat t\u00E4m\u00E4n toiminnon k\u00E4yt\u00F6st\u00E4, voit halutessasi tarkistaa p\u00E4ivitysten saatavuuden vali"
  152.                             + "tsemalla Ohje > Tarkista p\u00E4ivitykset nyt...",
  153.             "IDS_UDWEEKLYDESCTEXT_RDR" : "Adobe Reader voi tarkistaa automaattisesti kerran viikossa, onko t\u00E4rkeit\u00E4 p\u00E4ivityksi\u00E4 tai ilmoituksia saatavana. Jos poistat t\u00E4m\u00E4n toiminnon k\u00E4yt\u00F6st\u00E4, voit halutessasi tarkistaa p\u00E4ivitysten saatavuuden valit"
  154.                             + "semalla Ohje > Tarkista p\u00E4ivitykset nyt..."
  155.         },
  156.         "SVE" :
  157.         {
  158.             "IDS_UDWEEKLYDESCTEXT_ACRO" : "Adobe Acrobat kan automatiskt kontrollera om det finns viktiga uppdateringar och meddelanden en g\u00E5ng i veckan. Om du inaktiverar den h\u00E4r funktionen kan du s\u00F6ka efter uppdateringar manuellt genom att v\u00E4lja Hj\u00E4lp > Leta efter uppdater"
  159.                             + "ingar nu.",
  160.             "IDS_UDWEEKLYDESCTEXT_RDR" : "Adobe Reader kan automatiskt kontrollera om det finns viktiga uppdateringar och meddelanden en g\u00E5ng i veckan. Om du inaktiverar den h\u00E4r funktionen kan du s\u00F6ka efter uppdateringar manuellt genom att v\u00E4lja Hj\u00E4lp > Leta efter uppdateri"
  161.                             + "ngar nu."
  162.         }
  163.     },
  164.  
  165.     getPrefPanelLocStr: function(strID)
  166.     {
  167.         updater.MasterScript.assert(strID && (strID.length > 0), "invalid string id");
  168.  
  169.         var appLang = updater.MasterScript.getAppLang();
  170.         if (updater.MasterScript.PropertyIsDefined(updater.MasterScript.PrefPanelLocJSStrings, appLang))
  171.         {
  172.             var strRes = updater.MasterScript.PrefPanelLocJSStrings[appLang];
  173.  
  174.             if (updater.MasterScript.PropertyIsDefined(strRes, strID))
  175.             {
  176.                 return strRes[strID];
  177.             }
  178.             else
  179.             {
  180.                 // Try ENU if strID is missing from nonENU string resource.
  181.                 strRes = updater.MasterScript.PrefPanelLocJSStrings["ENU"];
  182.                 if (updater.MasterScript.PropertyIsDefined(strRes, strID))
  183.                 {
  184.                     return strRes[strID];
  185.                 }
  186.                 else
  187.                 {
  188.                     return "MISSING_STRID_" + strID;
  189.                 }
  190.             }
  191.         }
  192.         else
  193.         {
  194.             return "MISSING_STRING_RESOURCE_" + appLang;
  195.         }
  196.     },
  197.  
  198.     prodConfigToURLMap: {
  199.       "Exchange-Pro": "pro",
  200.       "Exchange" : "std",
  201.       "Reader" : "rdr"
  202.     },
  203.  
  204.     // msAVAcrobatRegionInternational: 0,
  205.     // msAVAcrobatRegionCentralEurope: 1,
  206.     // msAVAcrobatRegionMiddleEast: 2,
  207.  
  208.     regionSpecifiers:
  209.     [
  210.         "",
  211.         "-ce",
  212.         "-me"
  213.     ],
  214.  
  215.     scriptRootTemplate: "_PRODCONF_/_PLATFORM_/_LANG_/",
  216.  
  217.     getScriptRootURL: function()
  218.     {
  219.       var prod, platform, lang;
  220.       var region = updater.app.viewerRegion;
  221.       
  222.       prod = this.prodConfigToURLMap[updater.app.viewerType];
  223.       this.assert(prod.length > 0, "Invalid Product Config");
  224.       
  225.       var regSpec = updater.MasterScript.regionSpecifiers[updater.app.viewerRegion];
  226.       prod += regSpec;
  227.  
  228.       
  229.       platform = updater.app.platform.toLowerCase();
  230.  
  231.       var lang;
  232.  
  233.       var tier = this.getAppTier();
  234.  
  235.       // user is in cross tier config
  236.       if (tier.toLowerCase() == "all") { lang = "all"; }
  237.       else if (tier.toLowerCase() == "enu") { lang = "enu"; }
  238.       // else { lang = this.getDefLangForTier(tier).toLowerCase(); }
  239.       // always use running lang to produce the URL
  240.       else { lang = this.getAppLang().toLowerCase(); }
  241.  
  242.       var urlext = new String(this.scriptRootTemplate);
  243.  
  244.       urlext = urlext.replace(/_PRODCONF_/, prod);
  245.       urlext = urlext.replace(/_PLATFORM_/, platform);      
  246.       urlext = urlext.replace(/_LANG_/, lang);
  247.       
  248.       updater.console.println("url ext = " + urlext);
  249.       
  250.       return updater.scriptRootURL + urlext;
  251.     },
  252.     
  253.     getDSURL: function()
  254.     {
  255.         var dsfile = "DataScript.js";
  256.         var ret = this.getScriptRootURL() + dsfile;
  257.         return ret;
  258.     },
  259.  
  260.  
  261.     //
  262.     // The App Tier and Language  API
  263.     //
  264.     // The Language code
  265.     //
  266.     //      {"DEU", "de-DE"},
  267.     //         {"ESP", "es-ES"},
  268.     //         {"FRA", "fr-FR"},
  269.     //         {"ITA", "it-IT"},
  270.     //         {"JPN", "ja-JP"},
  271.     //         {"NLD", "nl-NL"},
  272.     //         {"SVE", "sv-SE"},
  273.     //         {"SUO", "fi-FI"},
  274.     //         {"NOR", "no-NO"},
  275.     //         {"NON", "no-NO"},
  276.     //         {"DAN", "da-DK"},
  277.     //         {"KOR", "ko-KR"},
  278.     //         {"PTB", "pt-BR"},
  279.     //         {"CHS", "zh-CN"},
  280.     //         {"CHT", "zh-TW"},
  281.     //         {"ENU", "en-US"}
  282.     //
  283.   
  284.     // language code id to description
  285.     LangToDescMap:
  286.     {
  287.     "ENU" : "English",
  288.     "JPN" : "Japanese",
  289.     "CHT" : "Chinese Traditional",
  290.     "CHS" : "Chinese Simplified",
  291.     "KOR" : "Korean",
  292.     "FRA" : "French",
  293.     "DEU" : "German",
  294.     "PTB" : "Portuguese Brazil",
  295.     "ITA" : "Italian",
  296.     "NLD" : "Dutch",
  297.     "ESP" : "Spanish",
  298.     "SVE" : "Swedish",
  299.     "DAN" : "Danish",
  300.     "SUO" : "Finish",
  301.     "NOR" : "Norwegian",
  302.     "HEB" : "Hebrew",
  303.     "ARA" : "Arabic"
  304.     },
  305.  
  306.     // Map either ISO4Char or RFC1766 to language code id
  307.     CountryToLangMap: 
  308.     {
  309.     "en"    : "ENU",
  310.     "en-us" : "ENU",
  311.     "ja"    : "JPN",
  312.     "ja-jp" : "JPN",
  313.     "zh-tw" : "CHT",
  314.     "zh_tw" : "CHT",
  315.     "zh-cn" : "CHS",
  316.     "zh_cn" : "CHS",
  317.     "ko"    : "KOR", 
  318.     "ko-kr" : "KOR",
  319.     "fr"    : "FRA",
  320.     "fr-fr" : "FRA",
  321.     "de"    : "DEU",
  322.     "de-de" : "DEU",
  323.     "pt"    : "PTB",
  324.     "pt-br" : "PTB",
  325.     "it"    : "ITA",
  326.     "it-it" : "ITA",
  327.     "nl"    : "NLD",
  328.     "nl-nl" : "NLD",
  329.     "es"    : "ESP",
  330.     "es-sp" : "ESP",
  331.     "sv"    : "SVE",
  332.     "sv-se" : "SVE",
  333.     "da"    : "DAN",
  334.     "da-dk" : "DAN",
  335.     "fi"    : "SUO",
  336.     "fi-fi" : "SUO",
  337.     "no"    : "NOR",
  338.     "no-no" : "NOR",
  339.     "he"    : "HEB",
  340.     "he-il" : "HEB",
  341.     "ar"    : "ARA",
  342.     "ar-ae" : "ARA"
  343.     },
  344.  
  345.     // TODO: need to update the tier map
  346.     // Map Tier to lang in lang code id
  347.     TierToLangsMap:
  348.     [
  349.         // IE
  350.         {
  351.             "EFGJ"            : ["FRA", "DEU", "JPN"],
  352.             "CCK"            : ["CHT", "CHS", "KOR"],
  353.             "DDNSFSIP"        : ["DAN", "NLD", "NOR", "SVE", "SUO", "ESP", "ITA", "PTB"]
  354.         },
  355.         // CE
  356.         {
  357.             "CPG"    : ["CZE", "POL", "GRE"],
  358.             "HS"    : ["HUN", "SLV"],
  359.             "RTHR"    : ["RUS", "TUR", "HRV", "RUM"]
  360.         },
  361.         // ME
  362.         {
  363.             "H"    : ["HEB"],
  364.             "A"    : ["ARA"]
  365.         }
  366.     ],
  367.     
  368.     tierIndLangs:
  369.     [
  370.         // IE
  371.         {
  372.             "ENU"    : true
  373.         },
  374.         // CE
  375.         {
  376.             "ENU"    : true
  377.         },
  378.         // ME
  379.         {
  380.             "ENU"    : true,
  381.             "FRA"    : true
  382.         }
  383.     ],
  384.  
  385.     getAppLang: function() {
  386.       if ( ! updater.MasterScript.PropertyIsDefined(updater, "appLang") ||
  387.            updater.appLang == null ) 
  388.         {
  389.         updater.appLang = updater.app.language;
  390.         }
  391.       return updater.appLang;
  392.     },
  393.   
  394.     // Returns
  395.     // 1. ENU iff ENU is the only lang the app has
  396.     // 2. ALL if app has cross tier lang res
  397.     // 3. one of the key in TierToLangsMap reflecting the tier app is in
  398.     getAppTier: function() {
  399.  
  400.       if ( updater.MasterScript.PropertyIsDefined(updater, "appTier") &&
  401.            updater.appTier != null ) {
  402.         return updater.appTier;
  403.         }
  404.  
  405.       updater.console.println("app is running with lang = " + this.getAppLang());
  406.     
  407.       // determine tier
  408.       var res;
  409.       try {
  410.         res = this.getLangRes();
  411.         }
  412.       catch (e) {
  413.         updater.console.println("Exception calling getLangRes()" + e);
  414.         this.assert(false, "  getLangRes() exception");
  415.         updater.console.println("  defaulting res to ENU");
  416.         res = new Array();
  417.         res[0] = "ENU";
  418.         }
  419.     
  420.       updater.console.println("app has follow lang resources = " + res);
  421.  
  422.       if (res.length == 1) { 
  423.         // if the app has ONLY single lang has, it MUST be ENU
  424.         updater.MasterScript.assert(res[0] == "ENU", "Single Lang res MUST be ENU");
  425.         updater.appTier = res[0];
  426.         return res[0]; 
  427.         }
  428.     
  429.       var dup = {};  // used as a boolean bitmap
  430.       var t = Array();  // list of tiers
  431.       
  432.       // narrow down to Tiers given all the res available
  433.       var indLangs = updater.MasterScript.tierIndLangs[updater.app.viewerRegion];
  434.       
  435.         var swedishOnMacFound = false;
  436.         for (var i in res)
  437.         {
  438.             if (updater.MasterScript.PropertyIsDefined(indLangs, res[i]) && indLangs[res[i]])
  439.             {
  440.                 continue;
  441.             }
  442.             
  443.             // Work around a bug introduced in 7.0.1 where the Swedish side-car file was added
  444.             // to all combinations of Mac installers.  This has the unfortunate side effect of
  445.             // making various tiered released look like multitier releases.  For example, an
  446.             // EFGJ release with the Swedish resource appears to have both EFGJ and DDNSFSIP.
  447.             // The [gross] solution is to ignore Swedish when deciding what tier a particular
  448.             // release belongs to.  This should still work even when we want to detect the
  449.             // DDNSFSIP tier, because the other language resources should be present which
  450.             // should be enough to detect that tier.
  451.             if (res[i] == "SVE" && updater.app.platform == "MAC")
  452.             {
  453.                 swedishOnMacFound = true;
  454.                 continue;
  455.             }
  456.             
  457.             var tier = this.mapLangToTier(res[i], updater.app.viewerRegion);
  458.             if (tier != null && !updater.MasterScript.PropertyIsDefined(dup, tier))
  459.             {
  460.                 dup[tier] = true;
  461.                 t.push(tier);
  462.             }
  463.         }
  464.         
  465.         // Handle the special case on the Mac (see bug fix above for Swedish) where the
  466.         // ONLY side-car file found is Swedish.  In that case, still treat it as DDNSFSIP.
  467.         if (swedishOnMacFound && (t.length == 0))
  468.         {
  469.             var tier = this.mapLangToTier("SVE", updater.app.viewerRegion);
  470.             if (tier != null)
  471.             {
  472.                 t.push(tier);
  473.             }
  474.         }
  475.         
  476.         updater.console.println("app is in tier = " + t);
  477.         
  478.         if (t.length == 1) 
  479.         {
  480.             updater.appTier = t[0];
  481.         }
  482.         else 
  483.         {
  484.             updater.console.println("app is in Multi-Tier = " + t);
  485.             updater.appTier = "ALL";
  486.         }
  487.  
  488.       return updater.appTier;
  489.     },
  490.     
  491.     mapLangToTier : function(lang, region)
  492.     {
  493.         var retTier = null;
  494.         if (region >= updater.MasterScript.msAVAcrobatRegionInternational && region <= updater.MasterScript.msAVAcrobatRegionMiddleEast)
  495.         {
  496.             var m = updater.MasterScript.TierToLangsMap[region];
  497.             for (var tier in m)
  498.             {
  499.                 var langStr = m[tier]; // array of lang strings
  500.                 for (var i in langStr)
  501.                 {
  502.                     if (lang.toLowerCase() == langStr[i].toLowerCase())
  503.                     {
  504.                         retTier = tier;
  505.                     }
  506.                 }
  507.             }
  508.         }
  509.         
  510.         if (retTier == null)
  511.         {
  512.             updater.MasterScript.assert(false, "Input lang (" + lang + ") or region (" + region + ") invalid.");
  513.         }
  514.         return retTier;
  515.     },
  516.   
  517.     // return array of resources in Country Code app has.
  518.     // ENU MUST always be in the array.
  519.     getLangRes: function() {
  520.       updater.console.println("getLangRes()");
  521.       var langRet = new Array();
  522.       var idx = 0;
  523.       
  524.       // Get path to app root folder
  525.       var avSpCat = updater.fileSys.AVSpecialCategory;
  526.       var avSpFold = updater.fileSys.AVSpecialFolder;
  527.       var resRoot = updater.fileSys.GetSpecialFolder(avSpCat["kAVSCApp"], avSpFold["kAVSFRoot"]);
  528.  
  529.       if (updater.app.platform == "WIN") 
  530.       {
  531.         var type = updater.app.viewerType;
  532.         var winLangFileBase;
  533.         if ( type == "Reader" ) {
  534.            winLangFileBase = "RdLang32";
  535.           }
  536.         else {
  537.           winLangFileBase = "ExLang32";
  538.           }
  539.           
  540.         // win always has ENU
  541.         langRet[idx++] = "ENU";
  542.           
  543.         // Don't enum all files in the app root folder (way too slow), instead, check for specific files
  544.         for (var i in updater.MasterScript.LangToDescMap)
  545.         {
  546.             if (i.toUpperCase() == "ENU")
  547.             {
  548.                 continue;
  549.             }
  550.             
  551.             var sideCarExt = i;
  552.             var sideCarFile = winLangFileBase + "." + sideCarExt;
  553.             var sideCarPath = resRoot.mdPath + sideCarFile;
  554.             updater.console.println("  Looking for side car file " + sideCarPath);
  555.             
  556.             var fileProps = updater.fileSys.getFileProps(sideCarPath);
  557.             if (fileProps.isExistingFile)
  558.             {
  559.                 updater.console.println("  Found side car file " + sideCarPath);
  560.                 var lcode = sideCarExt.toUpperCase();
  561.                 updater.console.println(" lcode = " + lcode);
  562.                 if ( typeof(lcode) != "undefined" ) 
  563.                 {
  564.                     langRet[idx++] = lcode; 
  565.                 }
  566.             }
  567.         }
  568.       }
  569.       else if (updater.app.platform == "MAC") 
  570.       {
  571.         var macLangFileExt = "lproj";
  572.         
  573.         // no special folder defined to access lang resource folder.
  574.         // manually create the path from app root:
  575.         //    /Acrobat 7.0.app/Contents/MacOS/
  576.         // -->/Acrobat 7.0.app/Contents/Resources/
  577.         var dip = new String(resRoot.diPath);
  578.         var resPath = dip.replace(/MacOS/, "Resources");
  579.  
  580.         for (var i in updater.MasterScript.CountryToLangMap)
  581.         {
  582.             var resFolderBase = i;
  583.             var resFolder = resFolderBase + "." + macLangFileExt;
  584.             var resFolderPath = resPath + resFolder;
  585.             updater.console.println("  Looking for resource folder " + resFolderPath);
  586.             
  587.             var fileProps = updater.fileSys.getFileProps(resFolderPath, true);
  588.             if (fileProps.isExistingFolder)
  589.             {
  590.                 updater.console.println("  Found resource folder " + resFolderPath);
  591.                 updater.console.println(" cnt   = " + resFolderBase);
  592.                 var lcode = updater.MasterScript.CountryToLangMap[i];
  593.                 updater.console.println(" lcode = " + lcode);
  594.                 langRet[idx++] = lcode; 
  595.             }
  596.         }
  597.       }
  598.       else 
  599.       {
  600.         this.assert(false, "Unsupported platform : " + updater.app.platform);
  601.         return null;
  602.       }
  603.     
  604.       return langRet;
  605.     },
  606.  
  607.     // base.ext
  608.     getFileNameBase: function(fn) {
  609.       var sep = fn.indexOf(".");
  610.       if (sep == -1) return fn;
  611.       return fn.substring(0, sep);
  612.     },
  613.  
  614.     // base.ext
  615.     getFileNameExt: function(fn) {
  616.       var sep = fn.indexOf(".");
  617.       if (sep == -1) return "";
  618.       return fn.substring(sep + 1, fn.length);
  619.     },
  620.  
  621.  
  622.     // pop a dialog and return true if restart pending.
  623.     checkPendingRestart: function(silent) 
  624.     {
  625.       var restartPending;
  626.       
  627.       if ( typeof(updater["restartPending"]) != "undefined" && updater.restartPending == true) {
  628.         updater.console.println("===> App Restart Pending!  Skip Running Updater");
  629.         restartPending = updater.restartPending;
  630.         
  631.         // need restarting Acrobat...  
  632.         if (! silent) {
  633.           var title = updater.app.getUpdaterString("uisJSNeedRestartTitle");
  634.           var type = updater.app.viewerType;
  635.           var infoMsg;
  636.           if ( type == "Reader" ) {
  637.             infoMsg = updater.app.getUpdaterString("uisJSNeedRestartTxtRdr");
  638.             }
  639.           else {
  640.             infoMsg = updater.app.getUpdaterString("uisJSNeedRestartTxtVwr");
  641.             }
  642.           updater.app.alert({nIcon:3, nType:0, cTitle:title, cMsg:infoMsg});  
  643.           }
  644.         }
  645.       else {
  646.         restartPending = false;
  647.         }
  648.       return restartPending;
  649.     },
  650.  
  651.     // ALL MasterScript entry point MUST call init() before proceeding.
  652.     // if init() returns false, caller should exit and not proceed.
  653.     init: function(silent)
  654.     {
  655.       updater.console.println("MasterScript init() - silent = " + silent);
  656.       
  657.       if (updater.app.getUpdateDisabled()) {
  658.         updater.console.println("   Updater Disabled!!");
  659.         return false;
  660.       }
  661.       
  662.       // checkPendingRestart is the only init func for now.
  663.       // may have more MasterScript global init func later.
  664.       var ret = this.checkPendingRestart(silent);
  665.  
  666.       // don't cont if restart pending
  667.       var toCont = !ret;
  668.  
  669.       updater.console.println("MasterScript init() - to continue = " + toCont);
  670.       return (toCont);
  671.     },
  672.  
  673.     //
  674.     // Main Entry point for doing manual or auto updates
  675.     //
  676.     // set force to true for manual update, otherwise, it determines if it is
  677.     // time to update for the auto update case
  678.     // 
  679.     entryPoint: function(force)
  680.     {
  681.         var timer = updater.MasterScript.CreateTimer("  Auto/Manual UD MasterScript entry point");
  682.         force ? this.ManualUpdateAsync() : this.AutoUpdateAsync();
  683.         updater.MasterScript.LogTimingInfo(timer, "  Exiting MasterScript entry point");
  684.     },
  685.  
  686.     // 
  687.     // utils function 
  688.     //
  689.     PropertyIsDefined: function( obj, propName )
  690.     {
  691.         var ret = (typeof( obj[ propName ] ) != "undefined");
  692.         // updater.console.println("PropertyIsDefined returns " + ret + " for " + propName);
  693.         return ret;
  694.     },
  695.  
  696.     DumpStrObj: function (obj) {
  697.       // updater.console.println("  ---- DumpStrObj -----");
  698.       updater.console.println("  obj.length = " + obj.length);
  699.       for (var i = 0; i < obj.length; i++) {
  700.         updater.console.println("  charcode obj[" + i + "] = " + obj.charCodeAt(i));
  701.       }
  702.       // updater.console.println("  ---- DumpStrObj End -----");
  703.     },
  704.     
  705.     // improve it to dump recursively later if i have time
  706.     DumpObject: function (obj, str, vals) {
  707.       if (! str ) str = "";
  708.       else str = str + " ";
  709.       str += "(" + obj + ") [" + typeof(obj) + "]\n";
  710.       for (var p in obj) {
  711.         str += "  " + p + ( vals ? ": " + obj[p] : "") + "\n";
  712.       }
  713.       updater.console.println(str);
  714.     },
  715.  
  716.     DumpArray: function (array, str) {
  717.       if (! str ) str = "";
  718.       else str = str + " ";
  719.       str += "(" + array + ") [" + typeof(array) + "]\n{ ";
  720.       for( var i = 0;  i < array.length;  i++ ) {
  721.         str += array[i] + ( i < array.length - 1 ? ", " : " }" );
  722.       }
  723.       updater.console.println(str);
  724.     },
  725.  
  726.     GetFunctionName: function(f) {
  727.       var name = f.toString().match(/(function .*\))/)[1];
  728.  
  729.       if ((name == null) || (name.length == 0))
  730.         name = 'anonymous';
  731.  
  732.       return name;
  733.     },
  734.  
  735.     StackTrace: function() 
  736.     {
  737.       var ret = '';
  738.       for (var i = arguments.callee.caller; i != null; i = i.caller) {
  739.         if (i) {
  740.           ret += '> ' + this.GetFunctionName(i) + '\n';
  741.         }
  742.         // if (i.caller == i) {
  743.         //           ret += '*';
  744.         //           break;
  745.         //         }
  746.       }
  747.       return ret;
  748.     },
  749.  
  750.     assert: function(cond, details) {
  751.       if (!cond) {
  752.         var msg = "!!!!! Assert failure ";
  753.         if (details) {
  754.           msg = msg + " - " + details;
  755.         }
  756.         if (arguments.callee.caller != null) {
  757.           msg = msg + "in " 
  758.                 + this.GetFunctionName(arguments.callee.caller)
  759.                 + ")";
  760.         }
  761.         msg = msg + "\n" + this.StackTrace();
  762.         updater.console.println(msg);
  763.       }
  764.     },
  765.  
  766.  
  767.     //
  768.     // convert a string in generalized ASN1 time format to JS Date Object
  769.     // returns null if conversion failed.  (it only support UTC as timezone.
  770.     // cannot convert between timezones yet)
  771.     // 
  772.     // eg:
  773.     // http last mod date:
  774.     // Date: Thu, 07 Nov 2002 10:09:38 GMT
  775.     // GEN_ASN1 eg1:
  776.     // "20021107061101Z"
  777.     //  012345678901234
  778.     // 
  779.     // GEN_ASN1 eg2:
  780.     // "20021107061101.27Z"
  781.     // 
  782.     // GEN_ASN1 eg3:
  783.     // "20021107061101.27-0200"
  784.     //
  785.     GenASN1ToDate: function (str) {
  786.  
  787.       var year, month, day, hours, mins, secs, ms, timezone;
  788.       var timeStr = new String(str);
  789.  
  790.       // has to be at least 14 or more chars
  791.       if (timeStr.length < 14) { return null; }
  792.  
  793.       year  = timeStr.substring(0 , 4);
  794.       month = timeStr.substring(4 , 6);
  795.       // zero based month used in JS Date
  796.       month = month - 1;
  797.       day   = timeStr.substring(6 , 8);
  798.       hours = timeStr.substring(8 , 10);
  799.       mins  = timeStr.substring(10, 12);
  800.       secs  = timeStr.substring(12, 14);
  801.  
  802. //       updater.console.println(year);
  803. //       updater.console.println(month);
  804. //       updater.console.println(day);
  805. //       updater.console.println(hours);
  806. //       updater.console.println(mins);
  807. //       updater.console.println(secs);
  808.  
  809.       
  810.       // if more than 14 chars, ms and/or timezone may be present
  811.       ms = 0; 
  812.       timezone = "Z";
  813.  
  814.       if (timeStr.length > 14) {
  815.         var plus, minus, zee, dot;
  816.         dot =  timeStr.indexOf(".", 14);
  817.         plus = timeStr.indexOf("+", 14);
  818.         minus = timeStr.indexOf("-", 14);
  819.         zee = timeStr.indexOf("Z", 14);
  820.  
  821. //         updater.console.println("dot = " + dot);        
  822. //         updater.console.println("plus = " + plus);
  823. //         updater.console.println("minus = " + minus);
  824. //         updater.console.println("zee = " + zee);
  825.  
  826.         // check if . exists, if so, try parse ms
  827.         //
  828.         // FIXME: ms parsing is NOT correct here....
  829.         // 0.5 should really be 500 ms, rather than 5 here.
  830.  
  831.         // must compare >= 0 to force numeric comparison instead of lexical
  832.         if (dot >= 0) {
  833.           if (zee >= 0) { ms = timeStr.substring( dot + 1, zee); }
  834.           else if (plus >= 0) { ms = timeStr.substring( dot + 1, plus); }
  835.           else if (minus >= 0) { ms = timeStr.substring( dot + 1, minus); } 
  836.           else { ms = 0; }
  837.         }
  838.  
  839. //        updater.console.println(ms);
  840.  
  841.         if (zee >= 0) { timezone = "Z"; }
  842.         else if (plus >= 0) { timezone = timeStr.substring( plus, plus + 5); }
  843.         else if (minus >= 0 ) { timezone = timeStr.substring( minus, minus + 5); }
  844.         else { timezone = "Z"; }
  845.  
  846. //        updater.console.println("timezone = " + timezone);
  847.       }
  848.  
  849.       //updater.console.println("returning");
  850.       return new Date(Date.UTC(year, month, day, hours, mins, secs, ms));
  851.     },
  852.  
  853.     // replace as many %s in str with replacements in array in order
  854.     ReplacePrintfToken: function(str, array) {
  855.       if (array.constructor != Array || array.length == 0) return str;
  856.       if (str.constructor != String || str.length == 0) return str;
  857.  
  858.       var token = "%s";
  859.       for (var i = 0; i < array.length; i++) {
  860.         str = str.replace(token, array[i]);
  861.         }
  862.       
  863.       return str;
  864.     },
  865.  
  866.     // 
  867.     // return Date Object
  868.     // the first update time is NOW
  869.     CreateFirstUpdateTime: function()
  870.     {
  871.         var t = new Date(); // current time in UTC
  872.         var ms = t.getTime();
  873.         var first = new Date(ms);
  874.         // updater.console.println("now = " + t);
  875.         // updater.console.println("next = " + next);
  876.  
  877.         return first;
  878.     },
  879.  
  880.     isTimeToUpdate: function()
  881.     {
  882.       // define nextCheckDate
  883.       // updater.console.println("isTimeToUpdate()");
  884.  
  885.         if (!this.PropertyIsDefined(updater, "nextCheckDate")) {
  886.           //updater.console.println("nextCheckDate not defined; define it now");
  887.           updater.nextCheckDate = this.CreateFirstUpdateTime();
  888.           updater.console.println("nextCheckDate = " + updater.nextCheckDate);          }
  889.  
  890.         //return true;
  891.  
  892.         var now = new Date();
  893.  
  894.         if (now.getTime() >= updater.nextCheckDate.getTime()) {
  895.             updater.console.println("-->It is time to do monthly auto update");
  896.             return true;
  897.         } else {
  898.             updater.console.println("-->It is NOT time to do monthly auto update yet.  will check on:");
  899.             updater.console.println(updater.nextCheckDate);
  900.             return false;
  901.         }
  902.     },
  903.  
  904.     advanceNextCheckDate: function()
  905.     {
  906.         updater.console.println("advanceNextCheckDate()");
  907.         var fuss = ((Math.random() * 3) + 4) * (1000 * 60 * 60 * 24); // in ms
  908.         var now_d = new Date();
  909.         var now_ms = now_d.getTime();
  910.         var next_ms = updater.nextCheckDate.getTime();
  911.         next_ms = (next_ms >= now_d.ms - 12*60*60*1000) ? next_ms + fuss : now_ms + fuss;
  912.         var later = new Date(next_ms);
  913.         updater.nextCheckDate = later;
  914.     },
  915.     
  916.     // All items not in the server-side files that should go in the js cache (ie, udstore.js) 
  917.     // need to be represented in UpdateFromStore().
  918.     UpdateFromStore: function()
  919.     {
  920.       if (updater.MasterScript.PropertyIsDefined(updater.store.perUser, "nextCheckDate")) 
  921.       {
  922.         updater.nextCheckDate = new Date(Date.parse(updater.store.perUser.nextCheckDate));
  923.         updater.console.println(".. nextCheckDate = " + updater.nextCheckDate);
  924.       }
  925.       
  926.       // viewed messages
  927.       if (updater.MasterScript.PropertyIsDefined(updater.store.perUser, "viewedMessages")) 
  928.       {
  929.         updater.viewedMessages = updater.store.perUser.viewedMessages;
  930.       }
  931.       else 
  932.       {
  933.         updater.viewedMessages = {};
  934.       }
  935.     },
  936.  
  937.     loadState: function()
  938.     {
  939.       updater.console.println("updater loading store");
  940.       try {
  941.         updater.store.load();
  942.         }
  943.       catch (e) {
  944.         updater.console.println("Exception in loadState(): " + e);
  945.         updater.console.println("  --> skip loading store");
  946.         }
  947.         
  948.         updater.MasterScript.UpdateFromStore();
  949.     },
  950.  
  951.     // All items not in the server-side files that should go in the js cache (ie, udstore.js) 
  952.     // need to be represented in UpdateStore().
  953.     UpdateStore: function()
  954.     {
  955.         if (updater.MasterScript.PropertyIsDefined(updater, "nextCheckDate")) 
  956.         {
  957.             updater.store.perUser.nextCheckDate = updater.nextCheckDate.toUTCString();
  958.         }
  959.  
  960.         if (updater.MasterScript.PropertyIsDefined(updater, "viewedMessages")) 
  961.         {
  962.             updater.store.perUser.viewedMessages = updater.viewedMessages;
  963.         }
  964.     },
  965.     
  966.     saveState: function()
  967.     {
  968.       updater.console.println("updater saving store");
  969.       updater.MasterScript.UpdateStore();
  970.  
  971.       try {
  972.         updater.store.save();
  973.         }
  974.       catch (e) {
  975.         updater.console.println("Exception in saveState(): " + e);
  976.         throw new Error("SaveStateException");
  977.         }
  978.     },
  979.  
  980.     // will pop up a dialog warning user if no net connection is found
  981.     checkNetConnection: function(skipUI) 
  982.     {
  983.       var hasNet; 
  984.       if ( typeof(updater.net["isConnected"]) != "undefined") {
  985.         hasNet = updater.net.isConnected();
  986.         }
  987.       else {
  988.         hasNet = updater.dlm.hasNetAccess();
  989.         }
  990.       
  991.       if (!hasNet && !skipUI) {
  992.         var title = updater.app.getUpdaterString("bsJSNoNetConnectTitle");
  993.         var errMsg = updater.app.getUpdaterString("bsJSNoNetConnectText");
  994.         updater.app.alert({nIcon:0, nType:0, cTitle:title, cMsg:errMsg});
  995.       }
  996.       
  997.       return hasNet;
  998.       
  999.     },
  1000.  
  1001.  
  1002.     // dialog for missing component
  1003.     showMissingCompDialog: function(cName) {
  1004.       var text;
  1005.       var title = updater.app.getUpdaterString("csJSMissCompTitle");
  1006.       
  1007.       if (!cName || cName.length == 0) {
  1008.         text = updater.app.getUpdaterString("csJSMissCompText");
  1009.         }
  1010.       else {
  1011.         text = updater.MasterScript.ReplacePrintfToken(updater.app.getUpdaterString("csJSMissCompTextName"),
  1012.                                                        [cName]);
  1013.         }
  1014.       return updater.app.alert({nIcon:2, nType:2, cTitle:title, cMsg:text});
  1015.     },
  1016.  
  1017.     wellKnownCompDesc: {
  1018.       "Plugin/EBook" : function() {
  1019.         return updater.app.getUpdaterString("IDS_SAI_EBOOK_NAME");
  1020.       },
  1021.       
  1022.       "Plugin/MultiMedia": function() { 
  1023.         return updater.app.getUpdaterString("IDS_SAI_MULTIMEDIA_NAME");
  1024.       },
  1025.       
  1026.       "Plugin/PictureTasks": function() { 
  1027.         return updater.app.getUpdaterString("IDS_SAI_MULTIMEDIA_NAME");
  1028.       },
  1029.  
  1030.       "Annot/Screen": function() { 
  1031.         return updater.app.getUpdaterString("IDS_SAI_MULTIMEDIA_NAME");
  1032.       },
  1033.  
  1034.       "Annot/Movie": function() { 
  1035.         return updater.app.getUpdaterString("IDS_SAI_MULTIMEDIA_NAME");
  1036.       },
  1037.  
  1038.       "AsianFont/TChn": function() { 
  1039.         return updater.app.getUpdaterString("IDS_SAI_ASIANFONT_CHT_NAME");
  1040.       },
  1041.  
  1042.       "AsianFont/SChn": function() { 
  1043.         return updater.app.getUpdaterString("IDS_SAI_ASIANFONT_CHS_NAME");
  1044.       },
  1045.  
  1046.       "AsianFont/Japn": function() { 
  1047.         return updater.app.getUpdaterString("IDS_SAI_ASIANFONT_JPN_NAME");
  1048.       },
  1049.       
  1050.       "AsianFont/Kore": function() { 
  1051.         return updater.app.getUpdaterString("IDS_SAI_ASIANFONT_KOR_NAME");
  1052.       }
  1053.       },
  1054.  
  1055.     // First look up in updater.wellKnownCompDesc (maybe updated by
  1056.     // CodeScipt) if missing, then look up in
  1057.     // updater.MasterScript.wellKnownCompDesc (the default list)
  1058.     // returns a non zero length string if desc is known and found for comp
  1059.     lookUpWellKnownCompDesc: function(type, name) {
  1060.       var l;
  1061.       var key = type + "/" + name;
  1062.       if (updater.MasterScript.PropertyIsDefined(updater, "wellKnownCompDesc")) {
  1063.         updater.console.println("  using updater.wellKnownCompDesc");
  1064.         l = updater.wellKnownCompDesc;
  1065.         }
  1066.       else {
  1067.         updater.console.println("  using updater.MasterScript.wellKnownCompDesc"); 
  1068.         l = updater.MasterScript.wellKnownCompDesc;
  1069.         }
  1070.       if (! updater.MasterScript.PropertyIsDefined(l, key) ) {
  1071.         updater.console.println("  cannot find prop " + key);
  1072.         return null;
  1073.         }
  1074.       if (l[key].constructor == Function) {
  1075.         try {
  1076.           updater.console.println("  calling " + key + " as function");
  1077.           return l[key].call();
  1078.           }
  1079.         catch (e) {
  1080.           updater.console.println("Exception calling wellKnownCompDesc." + key);
  1081.           return null;
  1082.           }
  1083.         }
  1084.       else 
  1085.         return l[key];
  1086.     },
  1087.  
  1088.     // MasterScript Entry Point
  1089.     // app.findComponent()
  1090.     findComponent: function(type, name, desc, ver, params, silent)
  1091.     {
  1092.       try {
  1093.         return this.FindComponentAsync(type, name, desc, ver, params, silent);
  1094.         }
  1095.       catch (e) {
  1096.         updater.console.println("exception in findComponent: " + e);
  1097.         return false;
  1098.         }
  1099.     },
  1100.     
  1101.     // MasterScript entry point
  1102.     // app.checkForUpdate()
  1103.     checkForUpdate: function(type, name, ver, msg, params)
  1104.     {
  1105.         try
  1106.         {
  1107.             return this.CheckForUpdateAsync(type, name, ver, msg, params, true);
  1108.         }
  1109.         catch (e)
  1110.         {
  1111.             updater.console.println("exception in app.checkForUpdate(): " + e);
  1112.             return false;
  1113.         }
  1114.     },
  1115.     
  1116.     newPDFCheck: function(fileSizeHi, fileSizeLo, headBuf, headSize, tailBuf, tailSize)
  1117.     {
  1118.         var ret = false;
  1119.     
  1120.         try
  1121.         {
  1122.             ret = updater.MasterScript.NewPDFCheckAsync(fileSizeHi, fileSizeLo, headBuf, headSize, tailBuf, tailSize, true);
  1123.         }
  1124.         catch (e)
  1125.         {
  1126.             updater.console.println("exception in newPDFCheck(): " + e);
  1127.             ret = false;
  1128.         }
  1129.         
  1130.         return ret;
  1131.     },
  1132.  
  1133.     // MasterScript Entry Point
  1134.     //   this is called by the idle proc
  1135.     CheckDLMState: function()
  1136.     {
  1137.       try {
  1138.         updater.MasterScript.asset(false, "CheckDLMState is obsoleted and should not be called.  DLM state checking is now done by AutoUpdateAsync");
  1139.         return;
  1140.         }
  1141.       catch (e) {
  1142.         updater.console.println("exception in CheckDLMState: " + e);
  1143.         }
  1144.     },
  1145.  
  1146.  
  1147.     // find out which message-only notification user has not read and pop up
  1148.     // modal dialogs
  1149.     popNotifications: function()
  1150.     {
  1151.       try {
  1152.         updater.console.println("  MasterScript popNotifications()");
  1153.  
  1154.         if ( ! this.init(true) ) return;
  1155.  
  1156.         updater.console.println("popNotifications()");
  1157.  
  1158.         // since called AFTER doUpdate(), just need to check if required
  1159.         // scripts exist. also, check user pref. if so, pop new notifications
  1160.         var notiEnable = updater.avpref.get("Updater", "ShowNotifDialog", 
  1161.                                             updater.avpref.type["Boolean"], true);
  1162.         // bail out if user doesn't want to see notifications
  1163.         if (!notiEnable) { return; }
  1164.         
  1165.         var hasAllScripts = updater.MasterScript.getAllScriptsFromStore();
  1166.  
  1167.         updater.console.println("notiEnable = " + notiEnable);
  1168.         updater.console.println("hasAllScripts = " + hasAllScripts);
  1169.         if (notiEnable && hasAllScripts) {
  1170.           updater.DataScript.entryPoint({func:"popNotifications", args:{}});
  1171.           }
  1172.         updater.console.println("popNotifications() Done");
  1173.         }
  1174.       catch (e) {
  1175.         updater.console.println("exception in popNotifications: " + e);
  1176.         return false;
  1177.         }
  1178.     },
  1179.  
  1180.     // URL utils
  1181.     urlGetProgUI: {
  1182.       cancelled: false,
  1183.       initialize: function(dialog) 
  1184.         {
  1185.           currentDialog = dialog;
  1186.           this.cancelled = false;
  1187.         },
  1188.       commit: function(dialog) {},
  1189.       close: function()
  1190.         {
  1191.           if(currentDialog)
  1192.             {
  1193.             currentDialog.end();
  1194.             return true;
  1195.             } else return false;
  1196.         },
  1197.       "cncl": function(dialog) {
  1198.         updater.console.println("  cancelled progress dialog");
  1199.         this.cancelled = true;
  1200.         this.close();
  1201.       },
  1202.       description: {
  1203.         name: updater.app.getUpdaterString("msJSChkForUpdtTitle"),
  1204.         elements:
  1205.         [
  1206.             {
  1207.             type: "view",
  1208.             align_children: "align_left",
  1209.             elements: [
  1210.                 {
  1211.                 type: "static_text",
  1212.                 name: updater.app.getUpdaterString("msJSChkForUpdtText"),
  1213.                 alignment: "align_center",
  1214.                 width: 200
  1215.                 },
  1216.                 {
  1217.                 type: "view",
  1218.                 alignment: "align_fill",
  1219.                 align_children: "align_fill",
  1220.                 elements:[
  1221.                     {
  1222.                     type: "button",
  1223.                     item_id: "cncl",
  1224.                     name: updater.app.getUpdaterString("msJSChkForUpdtCancel"),
  1225.                     alignment: "align_center"
  1226.                     }
  1227.                   ]
  1228.                 }
  1229.               ]
  1230.             }
  1231.         ]
  1232.       }
  1233.     },
  1234.  
  1235.     urlMonTask: function()
  1236.     {
  1237.       try {
  1238.         updater.console.println("enter gURLMonTask");
  1239.         var mon = updater.gURLMon;
  1240.         if (! mon.done) { 
  1241.           updater.console.println("     gURLMonTask waits...");
  1242.           mon.wait();
  1243.         }
  1244.         else {
  1245.           updater.console.println("     gURLMonTask got all...");
  1246.          if (updater.gURLMonTask) {
  1247.             updater.app.clearInterval(updater.gURLMonTask);
  1248.             updater.gURLMonTask = null;
  1249.            }
  1250.          updater.MasterScript.urlGetProgUI.close();
  1251.         }
  1252.         updater.console.println("exit gURLMonTask");
  1253.         }
  1254.       catch (e) {
  1255.         if (updater.gURLMonTask) {
  1256.           updater.app.clearInterval(updater.gURLMonTask);
  1257.           updater.gURLMonTask = null;
  1258.           }
  1259.         updater.MasterScript.urlGetProgUI.close();
  1260.         updater.console.println("Exception in URLMonTask" + e);
  1261.       }
  1262.     },
  1263.  
  1264.     // ifModSinceDate: js Date obj
  1265.     urlGetAsyncJSUI: function(url, ifModSinceDate)
  1266.     {
  1267.       updater.console.println("Enter urlGetAsyncUI");
  1268.       if (updater.gURLMonTask || updater.gURLMon ) {
  1269.         updater.console.println("gURLMonTask or gURLMon non-null! throwing...");
  1270.         throw new Error("Fatal error: urlGetAsyncUI is in progress!!");
  1271.       }
  1272.  
  1273.       var taskStr = "updater.MasterScript.urlMonTask();";
  1274.       
  1275.       updater.console.println("--- Added IdleProc");
  1276.       if (ifModSinceDate) {
  1277.         updater.gURLMon = updater.net.urlGetAsync(url, ifModSinceDate.toUTCString());
  1278.       }
  1279.       else {
  1280.         updater.gURLMon = updater.net.urlGetAsync(url);
  1281.       }
  1282.       updater.gURLMonTask = updater.app.setInterval(taskStr, 1000);
  1283.       updater.gURLMon.wait();
  1284.       updater.app.execDialog(this.urlGetProgUI);
  1285.  
  1286.       if ( this.urlGetProgUI.cancelled ) {
  1287.         if (updater.gURLMonTask) {
  1288.           updater.app.clearInterval(updater.gURLMonTask);
  1289.           updater.gURLMonTask = null;
  1290.         }
  1291.         updater.gURLMon.cancel();
  1292.         updater.gURLMon = null;
  1293.  
  1294.         updater.console.println("urlGetAyncUI cancelled!  throwing...");
  1295.         throw new Error("urlGetAyncUI cancelled");
  1296.       }
  1297.       var resp = updater.gURLMon.response;
  1298.  
  1299.       updater.gURLMonTask = null;
  1300.       updater.gURLMon = null;
  1301.  
  1302.       updater.console.println("Exit urlGetAsyncUI");
  1303.       updater.console.println(" http response status = " + resp["Status"]);
  1304.       return resp;
  1305.     },
  1306.  
  1307.     // ifModSinceDate: js Date obj
  1308.     // use blocking updater.net.urlGet
  1309.     urlGetUI: function(url, ifModSinceDate, closeUI)
  1310.     {
  1311.       updater.console.println("Enter urlGetUI");
  1312.  
  1313.       // for backward compatibility
  1314. //       if ( !this.PropertyIsDefined(updater.app, "showProgressDialog") ) {
  1315. //         var resp;
  1316. //         if (ifModSinceDate) {
  1317. //           updater.console.println(" -- pt 1 ");          
  1318. //           resp = updater.net.urlGet(url, ifModSinceDate.toUTCString());
  1319. //           this.DumpObject(ifModSinceDate);
  1320. //           updater.console.println(" -- pt 2 "); 
  1321. //         }
  1322. //         else {
  1323. //           resp = updater.net.urlGet(url);
  1324. //         }
  1325. //         return resp;
  1326. //       }
  1327.  
  1328.       // new
  1329.       if (!updater.isAutoUpdate) {
  1330.         updater.app.showProgressDialog();
  1331.       }
  1332.       updater.app.processDialogEvent();
  1333.  
  1334.       var resp;
  1335.       if (ifModSinceDate) {
  1336.         updater.console.println(" start urlGet() using if-mod-since");
  1337.         resp = updater.net.urlGet(url, ifModSinceDate.toUTCString());
  1338.         updater.console.println(" done urlGet()");
  1339.         }
  1340.       else {
  1341.         updater.console.println(" start urlGet()");
  1342.         resp = updater.net.urlGet(url);
  1343.         updater.console.println(" done urlGet()"); 
  1344.         }
  1345.  
  1346.       updater.app.processDialogEvent();
  1347.       if (closeUI) {
  1348.         updater.app.hideProgressDialog();
  1349.         }
  1350.  
  1351.       // this.DumpObject(resp);
  1352.  
  1353.       if ( updater.app.isProgressDialogCancelled() ) {
  1354.         throw new Error("ProgressDialog Cancelled");
  1355.         }
  1356.       
  1357.       updater.console.println("Exit urlGetUI");
  1358.       return resp;
  1359.     },
  1360.  
  1361.  
  1362.     // ifModSinceDate: js Date obj
  1363.     // use Async updater.net.urlGetAsync
  1364.     urlGetAsyncUI: function(url, ifModSinceDate, closeUI)
  1365.     {
  1366.       updater.console.println("Enter urlGetUIAsync");
  1367.  
  1368.       // new
  1369.       // updater.isAutoUpdate is a gloabl
  1370.       if (! updater.isAutoUpdate) {
  1371.         updater.app.showProgressDialog();
  1372.       }
  1373.  
  1374.       var mon;
  1375.       if (ifModSinceDate) {
  1376.         updater.console.println(" calls updater.net.urlGetAsync() using if-mod-since");
  1377.         mon = updater.net.urlGetAsync(url, ifModSinceDate.toUTCString());
  1378.         }
  1379.       else {
  1380.         updater.console.println(" calls updater.net.urlGetAsync()");
  1381.         mon = updater.net.urlGetAsync(url);
  1382.         }
  1383.  
  1384.       // loop for waiting for async get
  1385.       updater.console.println(" start looping url mon");
  1386.       while (! mon.done) {
  1387.         //updater.console.println("  ...waiting mon");
  1388.         updater.app.processDialogEvent();
  1389.         mon.wait();
  1390.         updater.app.processDialogEvent();
  1391.         if ( updater.app.isProgressDialogCancelled() ) {
  1392.           updater.console.println("  ...cancelling mon");
  1393.           mon.cancel(); 
  1394.           // updater.app.processDialogEvent();
  1395.           updater.app.hideProgressDialog();
  1396.           throw "URLGetCancelled";
  1397.           }
  1398.         }
  1399.       if (closeUI) {
  1400.         updater.app.hideProgressDialog();
  1401.         }
  1402.  
  1403.       var resp = mon.response;
  1404.  
  1405.       updater.console.println("Exit urlGetUIAsync");
  1406.       return resp;
  1407.     },
  1408.  
  1409.     //
  1410.     // FixUp the cacheScriptName so that it is product and language
  1411.     // dependent
  1412.     // eg: cachedMasterScript -> cachedMasterScript_Exchange-Pro_JPN
  1413.     //     cachedDataScript -> cachedDataScript_Reader_FRA
  1414.     //
  1415.     FixUpCacheScriptName: function(str) {
  1416.       var ret = str + "_" + updater.app.viewerType + "_" + updater.app.language;
  1417.       return ret;
  1418.     },
  1419.     // 
  1420.     // updater.tmp
  1421.     // updater.MasterScript
  1422.     // updater.DataScript
  1423.     // updater.CodeScript
  1424.     // updater.UIScript
  1425.     //
  1426.  
  1427.     //
  1428.     // updater.store.perUser:
  1429.     //   cachedMasterScript = { cachedDate: Date, scriptObj: script };
  1430.     //   cachedDataScript
  1431.     //   cachedCodeScript
  1432.     //   cachedUIScript
  1433.     //   nextCheckDate
  1434.     // 
  1435.     // CachedScript obj is like { cachedDate: Date, scriptObj: script };
  1436.     //
  1437.     
  1438.     // The input scriptCacheName are cachedMasterScript, cachedDataScript,
  1439.     // cachedCodeScript, cachedUIScript, etc.
  1440.     // 
  1441.     // scriptCacheName are postpended with prodConfig and Lang:
  1442.     // eg: cachedMasterScript -> cachedMasterScript_Exchange-Pro_JPN
  1443.     //     cachedDataScript -> cachedDataScript_Reader_FRA
  1444.     //
  1445.     // the postpended names are the actually names used in udstore.js
  1446.     //
  1447.     GetCachedScriptObj: function(serializationRoot, // updater.store.perUser
  1448.                                  scriptCacheName) // cachedDataScript, name for a CachedScript obj
  1449.     {
  1450.       updater.console.println("  GetCachedScriptObj()");
  1451.       var cachedScriptObj = null;
  1452.       
  1453.       // Should validate input params here!
  1454.       if (! scriptCacheName || scriptCacheName.length <=0 ) { throw "InvalidCachedName"; };
  1455.       
  1456.       scriptCacheName = this.FixUpCacheScriptName(scriptCacheName);
  1457.       updater.console.println("  scriptCacheName = " + scriptCacheName);
  1458.       
  1459.       // var serializationRoot = updater.store.perUser;
  1460.       
  1461.       // Do we have a cached data script object? If so, grab the date
  1462.       // associated with it.  This represents the moddate (in server-time) of
  1463.       // the data.
  1464.  
  1465.       try {
  1466.         // try finding cachedScriptModDate from presisted script
  1467.         if ( this.PropertyIsDefined(serializationRoot, scriptCacheName) ) {
  1468.  
  1469.           // Looks like we have a cached data script obj.  Just to be safe,
  1470.           // we'll ensure that it has the required keys
  1471.           // var cachedScriptObj = serializationRoot.cachedDataScript;
  1472.           cachedScriptObj = serializationRoot[scriptCacheName];
  1473.  
  1474.           // the cachedScriptObj must have prop scriptObj and cachedData
  1475.           if ( !this.PropertyIsDefined( cachedScriptObj, "scriptObj" ) || !this.PropertyIsDefined( cachedScriptObj, "cachedDate" ) ) {
  1476.             updater.console.println("   corrupted scriptobj");
  1477.             // missing a critical prop! nuke the cache info
  1478.             // delete serializationRoot.cachedDataScript;
  1479.             delete serializationRoot[scriptCacheName];
  1480.             }
  1481.             // else {
  1482.             // setup to use the moddate of the data JS in an if-modified-since query
  1483.             // cachedScriptModDate = new Date(Date.parse(cachedScriptObj.cachedDate));
  1484.             //updater.console.println("  cachedScriptObj.cachedDate = " + cachedScriptModDate);
  1485.             // }
  1486.  
  1487.           // if older version of DataScript < 0.02
  1488.           // updater.console.println("  cachedScript version = " + cachedScriptObj.scriptObj.version);
  1489.           
  1490.           //if (cachedScriptObj.scriptObj.version < "0.02") {
  1491.           //updater.console.println(" has older DataScript.  force loading new one");
  1492.           //cachedScriptModDate = null;
  1493.           //}
  1494.           }
  1495.         }
  1496.       catch (e) {
  1497.         updater.console.println(" exception in finding out cachedScriptModDate ");
  1498.         updater.console.println(" setting cachedScriptModDate to null");
  1499.       }
  1500.       return cachedScriptObj;
  1501.     },
  1502.  
  1503.     GetCachedScriptModDate: function(cachedScriptObj)
  1504.     {
  1505.       updater.console.println("  GetCachedScriptModDate()");
  1506.       var cachedScriptModDate = null; 
  1507.       if ( cachedScriptObj && this.PropertyIsDefined( cachedScriptObj, "cachedDate" ) ) {
  1508.         cachedScriptModDate  = new Date(Date.parse(cachedScriptObj.cachedDate));
  1509.         }
  1510.       return cachedScriptModDate;
  1511.     },
  1512.  
  1513.     // returns a resp obj
  1514.     DownloadScript: function(scriptURL, cachedScriptModDate)
  1515.     {
  1516.       updater.console.println("  DownloadScript()");
  1517.       var resp;
  1518.       try {
  1519.         if (cachedScriptModDate) {
  1520.           updater.console.println("  Using if-mod-since");
  1521.           if (updater.useSyncRead) {
  1522.             resp = this.urlGetUI(scriptURL, cachedScriptModDate);
  1523.             }
  1524.           else {
  1525.             resp = this.urlGetAsyncUI(scriptURL, cachedScriptModDate);
  1526.             }
  1527.           }
  1528.         else {
  1529.           updater.console.println("  NOT Using if-mod-since");
  1530.           if (updater.useSyncRead) {
  1531.             resp = this.urlGetUI(scriptURL);
  1532.             }
  1533.           else {
  1534.             resp = this.urlGetAsyncUI(scriptURL);
  1535.             }
  1536.           }
  1537.         }
  1538.       catch (e) {
  1539.         if (e == "URLGetCancelled") {
  1540.           throw "DownloadCancelled";
  1541.         }
  1542.         updater.console.println("Exception raised from updater.net.urlGet() or urlGetAsync() - " + e);
  1543.         updater.app.hideProgressDialog();
  1544.         throw "URLGetException";
  1545.         }
  1546.       return resp;
  1547.     },
  1548.  
  1549.     // return a scriptObj 
  1550.     GetAndCacheScriptObjFromResp: function(cachedScriptObj, resp, 
  1551.                                            serializationRoot, scriptCacheName)
  1552.     {
  1553.       updater.console.println("  GetAndCacheScriptObjFromResp()");
  1554.       scriptCacheName = this.FixUpCacheScriptName(scriptCacheName);
  1555.       updater.console.println("  scriptCacheName = " + scriptCacheName);
  1556.  
  1557.       // If we succesfully downloaded the data script, or if we got a not-modified result, we need to grab the
  1558.       // date returned by the server, which we'll use as our new last-check date.  This avoids clock skew
  1559.       // between the local machine and the server.
  1560.       var serverDate = null;
  1561.  
  1562.       updater.console.println("  checking response status");
  1563.       if (!resp || ! this.PropertyIsDefined(resp, "Status")) {
  1564.         updater.app.hideProgressDialog();
  1565.         throw "NoReponseStatus";
  1566.       }
  1567.  
  1568.       updater.console.println("  http response status = " + resp["Status"]);
  1569.  
  1570.       // if-modified-since case
  1571.       if (resp["Status"] == 304) {
  1572.         updater.console.println("  if-mod-since used since server response status = " + resp["Status"]);
  1573.         // used the cached datascript
  1574.         // updater.DataScript = cachedScriptObj.scriptObj;
  1575.         return cachedScriptObj.scriptObj;
  1576.         }
  1577.  
  1578.       // all other server error
  1579.       if (resp["Status"] != 200) {
  1580.         updater.app.hideProgressDialog();          
  1581.         throw "ServerError";
  1582.         }
  1583.  
  1584.       // Status = 200
  1585.       updater.console.println("  got newer content from server");
  1586.       // updater.console.println("resp.Content = " + resp.Content.substr(0, 30));
  1587.       // Get rid of the old cached data since it is out of date
  1588.       // delete serializationRoot.cachedDataScript;
  1589.       delete serializationRoot[scriptCacheName];
  1590.       
  1591.       if ( this.PropertyIsDefined( resp.Headers, "Date" ) ) {
  1592.         serverDate = this.GenASN1ToDate( resp.Headers["Date"] );
  1593.         updater.console.println("  Got Server Date ");
  1594.         }
  1595.       else {
  1596.         // illegal HTTP response without a Date header!
  1597.         updater.console.println("  illegal HTTP response without a Date header!  throw!");
  1598.         updater.app.hideProgressDialog();
  1599.         throw "NoDateHeader";
  1600.         }
  1601.  
  1602.       // Get the new moddate for the downloaded data out of the HTTP response headers.  Per HTTP 1.1 spec
  1603.       // section 14.25, we'll first try to get the Last-Modified header.  Failing this, we'll use the value
  1604.       // of the date header (which we retrieved above and stored in serverDate)
  1605.       var newModDate;
  1606.       if ( this.PropertyIsDefined( resp.Headers, "Last-Modified" ) ) {
  1607.         updater.console.println("  using Last-Modified to cache");
  1608.         newModDate = this.GenASN1ToDate( resp.Headers["Last-Modified"] );
  1609.         }
  1610.       else {
  1611.         updater.console.println("  using serverDate to cache");
  1612.         newModDate = serverDate;
  1613.         }
  1614.       updater.console.println("  newModDate = " + newModDate);
  1615.       
  1616.       // eval the returned data.  If this pukes, it'll throw.  We'll put in a check for null as well
  1617.       // just to be paranoid
  1618.       updater.console.println("  Eval resp.Content ");
  1619.       var newScriptObj = eval( resp.Content );
  1620.       if ( newScriptObj == null ) {
  1621.         updater.console.println("  Something wrong while eval resp.Content.  throws!");
  1622.         updater.app.hideProgressDialog();
  1623.         throw "BadData";
  1624.         }
  1625.         
  1626.       // Put the new cached data where it belongs
  1627.       updater.console.println("  Caching Content");
  1628.       // serializationRoot.cachedDataScript = { cachedDate : newModDate, scriptObj : newScriptObj };
  1629.       serializationRoot[scriptCacheName] = { cachedDate : newModDate, scriptObj : newScriptObj };
  1630.       
  1631.       // updater.DataScript = newScriptObj;
  1632.       return newScriptObj;
  1633.     },
  1634.  
  1635.     // return scriptObj
  1636.     downloadAndCacheScript: function(scriptURL,
  1637.                                      serializationRoot, // updater.store.perUser
  1638.                                      scriptCacheName // cachedDataScript, name for a CachedScript obj
  1639.                                      ) {
  1640.  
  1641.       if (! scriptURL || scriptURL.length <=0 ) { throw "InvalidScriptURL"; };
  1642.       updater.console.println("===== downloadAndCacheScript =====");
  1643.       updater.console.println("   url = " + scriptURL);
  1644.  
  1645.       var cachedScriptObj = null;
  1646.       cachedScriptObj = this.GetCachedScriptObj(serializationRoot, scriptCacheName);
  1647.  
  1648.       var cachedScriptModDate = null;
  1649.       cachedScriptModDate = this.GetCachedScriptModDate(cachedScriptObj);
  1650.  
  1651.       var resp = null;
  1652.  
  1653.       resp = this.DownloadScript(scriptURL, cachedScriptModDate);
  1654.       
  1655.       var scriptObj = null;
  1656.       scriptObj = this.GetAndCacheScriptObjFromResp(cachedScriptObj, resp, 
  1657.                                                     serializationRoot, scriptCacheName);
  1658.  
  1659.       return scriptObj;
  1660.     },
  1661.  
  1662.  
  1663.     // return a script or null
  1664.     getScriptFromStore: function(serializationRoot, 
  1665.                                  scriptCacheName) {
  1666.       if (updater.MasterScript.PropertyIsDefined(serializationRoot, scriptCacheName)) {
  1667.         updater.console.println("getScriptFromStore got " + scriptCacheName);
  1668.         return serializationRoot[scriptCacheName].scriptObj;
  1669.         
  1670.         }
  1671.       else {
  1672.         updater.console.println("getScriptFromStore returns null ");
  1673.         return null;
  1674.         }
  1675.     },
  1676.  
  1677.     // bring all scripts to runtime from store
  1678.     // only called by popNotifications().
  1679.     // will NOT go to net and fetch latest script
  1680.     // return true if all scripts exist
  1681.     //
  1682.     // TODO: need to check ResourceScript as well 
  1683.  
  1684.     // TODO: even better, if DataScript exist, check it dependency list for
  1685.     // required scripts rather than just code in all scripts names here
  1686.  
  1687.     // FIXME: MUST CALL FixUpCacheScriptName!!! otherwise won't find any scripts
  1688.  
  1689.     getAllScriptsFromStore: function() {
  1690.       updater.console.println(" getAllScriptsFromStore()");
  1691.  
  1692.       if ( ! updater.MasterScript.PropertyIsDefined(updater, "DataScript")) {
  1693.         var ret = updater.MasterScript.getScriptFromStore(updater.store.perUser, 
  1694.                                                           this.FixUpCacheScriptName("cachedDataScript"));
  1695.         if (ret != null) { 
  1696.           updater.DataScript = ret; 
  1697.           }
  1698.         else { 
  1699.           updater.console.println("   missing from store - DataScript");
  1700.           return false; 
  1701.           }  // if DataScript not in store, other script cannot be
  1702.       }
  1703.  
  1704.       updater.MasterScript.assert(updater.DataScript, "update.DataScript undefined");
  1705.  
  1706.       updater.console.println("   got from store - DataScript");
  1707.  
  1708.       var depList = updater.DataScript.GetScriptDependency();
  1709.       updater.MasterScript.assert(depList.constructor == Array, "depList not an Array!");
  1710.       var idx = 0;
  1711.       var gotAll = false;
  1712.       updater.console.println("  depList.length = " + depList.length);
  1713.       while ( idx < depList.length ) {
  1714.       updater.console.println("  idx = " + idx);
  1715.  
  1716.         var sRoot = depList[idx]["serializationRoot"]; // updater.store.perUser
  1717.         var sCachName = depList[idx]["scriptCacheName"]; // "cachedCodeScript"
  1718.         var cPoint = depList[idx]["callPoint"]; // "CodeScript"
  1719.         
  1720.         if ( updater.MasterScript.PropertyIsDefined(updater, cPoint) ) {
  1721.           // already defined
  1722.           updater.console.println("   got " + cPoint);
  1723.           idx++;
  1724.           }
  1725.         else {
  1726.           // trying mounting from store
  1727.           var scpt = updater.MasterScript.getScriptFromStore(sRoot, this.FixUpCacheScriptName(sCachName));
  1728.           if (ret != null) { 
  1729.             updater[cPoint] = scpt;
  1730.             idx++;
  1731.             updater.console.println("   got from store - " + cPoint);
  1732.             }
  1733.           else {
  1734.             updater.console.println("   missing from store - " + cPoint);
  1735.             break;
  1736.             }
  1737.           }
  1738.         }
  1739.  
  1740.       if (idx == depList.length) { gotAll = true; };
  1741.       return gotAll;
  1742.     },
  1743.  
  1744.     // Dev Tests
  1745.     
  1746.     getTestMasterURL: function()
  1747.     {
  1748.         var testmaster = "TestMaster.js";
  1749.         var ret = updater.scriptRootURL + testmaster;
  1750.         return ret;
  1751.     },
  1752.  
  1753.  
  1754.     testExec: function()
  1755.     {
  1756.       // this.findComponent("annotation", "bumper sticker");
  1757.       this.popNotifications();
  1758.       
  1759. //       var d1 = "20021107061101Z";
  1760. //       var d2 = "20010315182201.27Z";
  1761. //       var d3 = "20020910213422.56-0200";
  1762.  
  1763. //       var res = updater.MasterScript.GenASN1ToDate(d1);
  1764. //       updater.console.println(" d1 = " + res.toUTCString());
  1765.  
  1766. //       var res = updater.MasterScript.GenASN1ToDate(d2);
  1767. //       updater.console.println(" d1 = " + res.toUTCString());
  1768.  
  1769. //       var res = updater.MasterScript.GenASN1ToDate(d3);
  1770. //       updater.console.println(" d1 = " + res.toUTCString());
  1771.  
  1772. //       return;
  1773.  
  1774.       updater.console.println("Start Updater Test");
  1775.  
  1776.         var testMasterURL = this.getTestMasterURL();
  1777.         var testScript;
  1778.         try {
  1779.           var resp;
  1780.           // resp = this.urlGetAsyncUI(testMasterURL);
  1781.           resp = updater.MasterScript.urlGetUI(testMasterURL, null, true);
  1782.           updater.console.println("  Got TestMaster");
  1783.           updater.TestMaster = eval(resp.Content);
  1784.           updater.console.println("  Eval TestMaster done");
  1785.  
  1786.           if (this.PropertyIsDefined(updater, "TestMaster")) {
  1787.             updater.TestMaster.exec();
  1788.             }
  1789.           else {
  1790.             updater.console.println("  Cannot load TestMaster");
  1791.             }
  1792.         }
  1793.         catch (e) {
  1794.           updater.console.println("exception while fetching TestMaster:  " + e);
  1795.         }
  1796.     },
  1797.     
  1798.     updaterPrefPanelDisableSrc:
  1799.     {
  1800.         initialize: function(dialog) {},
  1801.     },
  1802.     
  1803.     GetUpdaterPrefPanelDisabled: function()
  1804.     {
  1805.         var gPrefsPanelWidth = 550;
  1806.         
  1807.         var updaterPrefPanelDisableSrc = updater.MasterScript.updaterPrefPanelDisableSrc;
  1808.         updaterPrefPanelDisableSrc["description"] = 
  1809.         {
  1810.             name: "Update Prefs Panel",
  1811.             margin_height: 0,
  1812.             margin_width: 0,
  1813.             elements: 
  1814.             [
  1815.                 {
  1816.                     type: "cluster",
  1817.                     name: updater.app.getUpdaterString("IDS_PREFS_PANEL_UPDATE"),
  1818.                     dwidth: (gPrefsPanelWidth),
  1819.                     align_children: "align_left",
  1820.                     elements: 
  1821.                     [
  1822.                         {
  1823.                             type: "static_text",
  1824.                             name: updater.app.getUpdaterString("IDS_PREFS_PANEL_DISABLEDDESC"),
  1825.                             alignment: "align_fill"
  1826.                         }
  1827.                     ]
  1828.                 }
  1829.             ]
  1830.         };
  1831.         
  1832.         return updaterPrefPanelDisableSrc;
  1833.     },
  1834.  
  1835.     updaterPrefPanelSrc:
  1836.     {
  1837.       version: "0.01",
  1838.  
  1839.       inBackgroundText : updater.app.getUpdaterString("IDS_PREFS_PANEL_UPDATEINBACKGROUND"),
  1840.       monthlyText : updater.app.getUpdaterString("IDS_PREFS_PANEL_UPDATEMONTHLY"),
  1841.       manuallyText : updater.app.getUpdaterString("IDS_PREFS_PANEL_UPDATEMANUALLY"),
  1842.  
  1843.       // constants
  1844.       inBackground: 2,
  1845.       monthly: 1,
  1846.       manually: 0,
  1847.       
  1848.       nextCheckText: updater.app.getUpdaterString("IDS_PREFS_PANEL_NEXTCHECK"),
  1849.       manualNextCheck: updater.app.getUpdaterString("IDS_PREFS_PANEL_MANUALNEXTCHECK"),
  1850.  
  1851.       updateAcrobatNowText: updater.app.getUpdaterString("IDS_UPDATE_ACROBAT_NOW"),
  1852.       updateReaderNowText: updater.app.getUpdaterString("IDS_UPDATE_READER_NOW"),
  1853.  
  1854.  
  1855.       hasMsgFunc: function(arg) {
  1856.           updater.console.println("arg.returnVal = " + arg.returnVal);
  1857.           var hasMsg = (arg.returnVal > 0);
  1858.           arg["hasMsg"] = hasMsg;
  1859.           updater.console.println("inner hasMsg = " + hasMsg);
  1860.       },
  1861.  
  1862.       // TODO: need to unwind this to CodeScript
  1863.       initialize: function(dialog) {
  1864.         updater.console.println("updaterPrefDialog initialize");
  1865.  
  1866.         // this.l10n_init(dialog);
  1867.  
  1868.         var freq = updater.app.getUpdateFrequency();
  1869.         updater.console.println("  freq = " + freq);
  1870.  
  1871.         var choices = {};
  1872.         if (freq == this.inBackground)
  1873.         {
  1874.             updater.console.println("    using inBackground");
  1875.             choices[this.inBackgroundText] = 1;
  1876.             choices[this.monthlyText] = 0;
  1877.             choices[this.manuallyText] = 0;
  1878.             dialog.load({"autn" : false});
  1879.             dialog.load({"autd" : true});
  1880.             dialog.load({"naut" : false});
  1881.         } 
  1882.         else if (freq == this.monthly) 
  1883.         {
  1884.             updater.console.println("    using monthly");
  1885.             choices[this.inBackgroundText] = 0;
  1886.             choices[this.monthlyText] = 1;
  1887.             choices[this.manuallyText] = 0;
  1888.             dialog.load({"autn" : true});
  1889.             dialog.load({"autd" : false});
  1890.             dialog.load({"naut" : false});
  1891.         }
  1892.         else 
  1893.         {
  1894.             updater.console.println("    using manually");
  1895.             choices[this.inBackgroundText] = 0;
  1896.             choices[this.monthlyText] = 0;
  1897.             choices[this.manuallyText] = 1;
  1898.             dialog.load({"autn" : false});
  1899.             dialog.load({"autd" : false});
  1900.             dialog.load({"naut" : true});
  1901.         }
  1902.  
  1903.         // widths 
  1904.         var date;
  1905.         if (freq == this.monthly || freq == this.inBackground)
  1906.         {
  1907.             if (!updater.MasterScript.PropertyIsDefined(updater, "nextCheckDate"))
  1908.             {
  1909.                 updater.console.println("nextCheckDate not defined; define it now");
  1910.                 updater.nextCheckDate = updater.MasterScript.CreateFirstUpdateTime();
  1911.                 updater.console.println("nextCheckDate = " + updater.nextCheckDate);
  1912.             }
  1913.             
  1914.             date = "" + updater.nextCheckDate;
  1915.             dialog.load({"nctx" : this.nextCheckText});        
  1916.             dialog.load({"ckAc" : (date)});
  1917.         }
  1918.         else
  1919.         {
  1920.             dialog.load({ "ckAc" : "" });
  1921.             dialog.load({"nctx" : ""});        
  1922.         }
  1923.  
  1924.         var type = updater.app.viewerType;
  1925.         if ( type == "Reader" ) {
  1926.           dialog.load( { "text" : this.updateDescTextReader } );
  1927.           dialog.load( { "UpAc" : this.updateReaderNowText } );
  1928.           }
  1929.         else {
  1930.           dialog.load( { "text" : this.updateDescText } );
  1931.           dialog.load( { "UpAc" : this.updateAcrobatNowText } );
  1932.           }
  1933.  
  1934.         dialog.load( { "ShNo" : updater.app.getShowStartupNotifDialog() } );
  1935.         dialog.load( { "ShIC" : updater.app.getShowInstallCompDialog() } );
  1936.  
  1937.         // FIXME: 
  1938.         // enable Notification button only when there are messages
  1939.         // downloaded AND not restart pending!
  1940.         var hasAllScripts = updater.MasterScript.getAllScriptsFromStore();
  1941.  
  1942.         var hasMsgFuncArgs = { "hasMsg": false };
  1943.  
  1944.         if (hasAllScripts) {
  1945.           updater.DataScript.entryPoint({func: "GetNumMessages", 
  1946.                                          args:{}, callBack: this.hasMsgFunc,
  1947.                                          callBackArgs: hasMsgFuncArgs});
  1948.         };
  1949.  
  1950.         var hasMsg = hasMsgFuncArgs["hasMsg"];
  1951.  
  1952.         updater.console.println("outter hasMsg = " + hasMsg);
  1953.         var notiEnable = hasAllScripts && 
  1954.                          (! updater.MasterScript.checkPendingRestart(true))
  1955.                          && hasMsg;
  1956.  
  1957.         var hasUpsEnable = hasAllScripts &&
  1958.                            (! updater.MasterScript.checkPendingRestart(true));
  1959.                            
  1960.         dialog.enable( { "Noti" : notiEnable } );
  1961.         dialog.enable( { "InUp" : hasUpsEnable });
  1962.         dialog.createNotifier( { "InUp" : 0, "Noti" : 0 } );
  1963.       },
  1964.  
  1965.       // TODO: need to unwind this to CodeScript
  1966.       commit: function(dialog) {
  1967.         updater.console.println("updaterPrefDialog commit");
  1968.         
  1969.         var isMan = dialog.store("naut")["naut"];
  1970.         var isMonth = dialog.store("autn")["autn"];
  1971.         var isBackground = dialog.store("autd")["autd"];
  1972.  
  1973.         updater.console.println(" isMan = " + isMan);
  1974.         updater.console.println(" isMon  = " + isMonth);
  1975.         updater.console.println(" isBackground  = " + isBackground);
  1976.  
  1977.         updater.app.setUpdateFrequency((isBackground == 1) ? this.inBackground: 
  1978.             ((isMan == 1) ? this.manually : this.monthly));
  1979.         updater.app.setShowStartupNotifDialog(dialog.store("ShNo" )["ShNo"]);
  1980.         updater.app.setShowInstallCompDialog(dialog.store("ShIC")["ShIC"]);
  1981.       },
  1982.       
  1983.       show: function(dialog)
  1984.       {
  1985.         updater.console.println("updaterPrefDialog show");
  1986.         
  1987.         var ret = true;
  1988.         var errMsg;
  1989.         var title = updater.app.getUpdaterString("IDS_PREFS_PANEL_RESTARTREQ_TITLE");
  1990.         
  1991.         if(updater.app.getRestartRequired())
  1992.         {
  1993.             if (updater.app.viewerType == "Reader")
  1994.             {
  1995.                 errMsg = updater.app.getUpdaterString("IDS_PREFS_PANEL_RESTARTREQ_RDR");
  1996.             }
  1997.             else
  1998.             {
  1999.                 errMsg = updater.app.getUpdaterString("IDS_PREFS_PANEL_RESTARTREQ_VWR");
  2000.             
  2001.             }
  2002.             updater.app.alert({nIcon:3, nType:0, cTitle:title, cMsg:errMsg});
  2003.             
  2004.             // Set return value to indicate that the pref panel shouldn't show
  2005.             ret = false;
  2006.             updater.console.println("  restart required");
  2007.         }
  2008.         
  2009.         if (ret == true)
  2010.         {
  2011.             updater.app.setPrefPanelSeen();
  2012.             updater.console.println("  showing pref panel");
  2013.         }
  2014.         return ret;
  2015.       },
  2016.  
  2017.       // TODO: need to unwind this to CodeScript
  2018.       // manual update
  2019.       // "UpAc": function(dialog) {
  2020.       // updater.console.println("UpAc clicked");
  2021.       // updater.MasterScript.entryPoint(true);
  2022.       // },
  2023.       
  2024.       "InUp": function(dialog) {
  2025.         updater.console.println("InUp clicked");
  2026.         updater.DataScript.entryPoint({func:"ShowInstalledUpdatesDialog", args:{}});        
  2027.       },
  2028.  
  2029.       // TODO: need to unwind this to CodeScript
  2030.       "Noti": function(dialog) {
  2031.         updater.console.println("Noti clicked");
  2032.         updater.DataScript.entryPoint({func:"ShowNotifDialog", args:{}});
  2033.       },
  2034.       
  2035.       radioClicked: function(dialog, val)
  2036.       {
  2037.         updater.console.println("radioClicked() with " + val);
  2038.         if (val == this.monthly || val == this.inBackground)
  2039.         {
  2040.             var date;
  2041.             
  2042.             if (!updater.MasterScript.PropertyIsDefined(updater, "nextCheckDate"))
  2043.             {
  2044.                 updater.console.println("nextCheckDate not defined; define it now");
  2045.                 updater.nextCheckDate = updater.MasterScript.CreateFirstUpdateTime();
  2046.                 updater.console.println("nextCheckDate = " + updater.nextCheckDate);
  2047.             }
  2048.         
  2049.             date = "" + updater.nextCheckDate;
  2050.             dialog.load({"ckAc" : (date)});
  2051.             dialog.load({"nctx" : this.nextCheckText});        
  2052.         }
  2053.         else
  2054.         {
  2055.             dialog.load({ "ckAc" : "" });
  2056.             dialog.load({"nctx" : ""});
  2057.         }
  2058.       },      
  2059.       "autn": function(dialog) 
  2060.       {
  2061.         updater.console.println("autn clicked");
  2062.         dialog.load({"autn" : true});
  2063.         dialog.load({"autd" : false});
  2064.         dialog.load({"naut" : false});
  2065.         this.radioClicked(dialog, this.monthly);
  2066.       },
  2067.       "autd": function(dialog) 
  2068.       {
  2069.         updater.console.println("autd clicked");
  2070.         dialog.load({"autn" : false});
  2071.         dialog.load({"autd" : true});
  2072.         dialog.load({"naut" : false});
  2073.         this.radioClicked(dialog, this.inBackground);
  2074.       },
  2075.       "naut": function(dialog) 
  2076.       {
  2077.         updater.console.println("naut clicked");
  2078.         dialog.load({"autn" : false});
  2079.         dialog.load({"autd" : false});
  2080.         dialog.load({"naut" : true});
  2081.         this.radioClicked(dialog, this.manually);
  2082.       }
  2083.     },
  2084.     
  2085.  
  2086.    // Pref Panel
  2087.    GetUpdaterPrefPanel: function() {
  2088.       var updatePanelName = updater.app.getUpdaterString("IDS_PREFS_PANEL_UPDATE");
  2089.       var radioAutoNotify = (updater.app.getUpdaterString("IDS_PREFS_PANEL_AUTONOTIFY"));
  2090.       var radioAutoDL = (updater.app.getUpdaterString("IDS_PREFS_PANEL_AUTODL"));
  2091.       var radioNoAuto = (updater.app.getUpdaterString("IDS_PREFS_PANEL_NOAUTO"));
  2092.       var installedUpBtn = (updater.app.getUpdaterString("UIS_INUPS_INSTALLED_UPDATES"));
  2093.  
  2094.       var gStaticTextHeight = 13;
  2095.       var gPrefsPanelWidth = 550;
  2096.       var gPrefsPanelHeight = 390;
  2097.  
  2098.       var updaterPrefPanel = updater.MasterScript.updaterPrefPanelSrc;
  2099.       
  2100.       updaterPrefPanel["updateDescText"] = updater.MasterScript.getPrefPanelLocStr("IDS_UDWEEKLYDESCTEXT_ACRO");
  2101.       updaterPrefPanel["updateDescTextReader"] = updater.MasterScript.getPrefPanelLocStr("IDS_UDWEEKLYDESCTEXT_RDR");
  2102.  
  2103.       updaterPrefPanel["description"] = 
  2104.       {
  2105.       name: "Update Prefs Panel",
  2106.       margin_height: 0,
  2107.       margin_width: 0,
  2108.       elements: [
  2109.           {
  2110.           type: "cluster",
  2111.           name: (updatePanelName),
  2112.           dwidth: (gPrefsPanelWidth),
  2113.           dheight: (gPrefsPanelHeight),
  2114.           align_children: "align_left",
  2115.           elements: [
  2116.               {  
  2117.               type: "static_text",
  2118.               item_id: "text",
  2119.               alignment: "align_fill",
  2120.               height: (gStaticTextHeight*3)
  2121.               },
  2122.               {
  2123.               type: "view",
  2124.               align_children: "align_left",
  2125.               alignment: "align_center",
  2126.               elements: [
  2127.                   {
  2128.                     type: "view",
  2129.                     align_children: "align_left",
  2130.                     elements: 
  2131.                     [
  2132.                         {
  2133.                         type: "static_text",
  2134.                         item_id: "cfut",
  2135.                         alignment: "align_left",
  2136.                         name: (checkForUpdatesText)
  2137.                         },
  2138.                         {
  2139.                             type: "radio",
  2140.                             item_id: "autn",
  2141.                             group_id: "grp1",
  2142.                             name: (radioAutoNotify)
  2143.                         },
  2144.                         {
  2145.                             type: "radio",
  2146.                             item_id: "autd",
  2147.                             group_id: "grp1",
  2148.                             name: (radioAutoDL)
  2149.                         },
  2150.                         {
  2151.                             type: "radio",
  2152.                             item_id: "naut",
  2153.                             group_id: "grp1",
  2154.                             name: (radioNoAuto)
  2155.                         }
  2156.                                        
  2157.                     ]
  2158.                   }
  2159.                 ]
  2160.               },
  2161.               { 
  2162.                     type: "view",
  2163.                     align_children: "align_top",
  2164.                     alignment: "align_fill",
  2165.                     elements: 
  2166.                     [
  2167.                         { 
  2168.                             type: "static_text",
  2169.                             item_id: "nctx",
  2170.                             name: (updaterPrefPanel.nextCheckText)
  2171.                         },
  2172.                                         
  2173.                         {
  2174.                             type: "static_text",
  2175.                             item_id: "ckAc",
  2176.                             alignment: "align_fill",
  2177.                             height: (gStaticTextHeight*3)
  2178.                         }
  2179.                     ]
  2180.               },
  2181.               {
  2182.                   type: "button",
  2183.                   item_id: "Noti",
  2184.                   width: (gUpdateNowWidth),
  2185.                   name: (updateNotificationBtn)
  2186.               },
  2187.               {
  2188.                   type: "button",
  2189.                   item_id: "InUp",
  2190.                   width: (gUpdateNowWidth),
  2191.                   name: (installedUpBtn)
  2192.               },        
  2193.               {
  2194.               type: "gap",
  2195.               height: (gStaticTextHeight)
  2196.               },            
  2197.               {
  2198.               type: "check_box",
  2199.               item_id: "ShNo",
  2200.               name: (displayStartupNotifDlgText)
  2201.               },
  2202.               
  2203.               {
  2204.               type: "check_box",
  2205.               item_id: "ShIC",
  2206.               name: (showInstallCompDlgText)
  2207.               }
  2208.             ]
  2209.           }
  2210.         ]
  2211.       };
  2212.  
  2213.       return updaterPrefPanel;
  2214.     }, // GetUpdaterPrefPanel
  2215.     
  2216.     LoadPrefPanel: function(panelIsEnabled)
  2217.     {
  2218.         try
  2219.         {
  2220.             updater.console.println("  MasterScript LoadPrefPanel()");
  2221.             
  2222.             if (!this.init(true)) 
  2223.             {
  2224.                 return;
  2225.             }
  2226.             
  2227.             updater.MasterScript.UpdateFromStore();
  2228.             
  2229.             if (panelIsEnabled)
  2230.             {
  2231.                 updater.prefPanel = updater.MasterScript.GetUpdaterPrefPanel();
  2232.             }
  2233.             else
  2234.             {
  2235.                 updater.prefPanel = updater.MasterScript.GetUpdaterPrefPanelDisabled();
  2236.             }
  2237.             return updater.prefPanel;
  2238.         }
  2239.         catch(e)
  2240.         {
  2241.             updater.console.println("exception in LoadPrefPanel: " + e);
  2242.             return null;
  2243.         }
  2244.     },
  2245.  
  2246.     //
  2247.     // General way of creating a state machine 
  2248.     //
  2249.     SStartStateMachine : function(idleProc, idleArgs, 
  2250.                                   resumeProc, resumeArgs, 
  2251.                                   name, states)
  2252.     {
  2253.       if (this.PropertyIsDefined(updater, "gStateMachineLock") &&
  2254.           updater.gStateMachineLock == true) {
  2255.         updater.console.println("SStartStateMachine locked by " + 
  2256.                                 updater.gStateMachine.name);
  2257.         throw "StateMachineInUse";
  2258.         }
  2259.       
  2260.       var timer = updater.MasterScript.CreateTimer("  SStartStateMachine() entry");
  2261.       updater.gStateMachineLock = true;
  2262.  
  2263.       // TODO: add singleton
  2264.       updater.gStateMachine = new Object();
  2265.       var sm = updater.gStateMachine;
  2266.  
  2267.       sm.name = name;
  2268.       sm.enumStates = states;
  2269.       sm.state = states.StInit;
  2270.       sm.idleProc = idleProc;
  2271.       sm.idleArgs = idleArgs;
  2272.       sm.resumeProc = resumeProc;
  2273.       sm.resumeArgs = resumeArgs;
  2274.       sm.done = false;
  2275.       sm.error = false;
  2276.       sm.exception = null;
  2277.       // TODO: the interval in ms MUST BE greater than the ADM idle proc
  2278.       // otherwise cancel event won't be received!
  2279.       sm.handle = updater.app.setInterval(idleProc, 60);
  2280.       updater.MasterScript.LogTimingInfo(timer, "    register JS download idle proc");
  2281.       updater.MasterScript.LogTimingInfo(timer, "  SStartStateMachine() exit");
  2282.     },
  2283.  
  2284.  
  2285.     // BgDl = Background downloading
  2286.     SBgDlStates : 
  2287.     {
  2288.       StInit: 0,
  2289.       StReadStart: 1,
  2290.       StReadWait: 2,
  2291.       StReadDone: 3,
  2292.       StShowUI: 4,
  2293.       StProcessUI: 5,
  2294.       StException: 800,
  2295.       StFinished: 999
  2296.     },
  2297.  
  2298.     //
  2299.     // This is the state machine for doing download MULTIPLE script, posting
  2300.     // progress dialog, cache script, etc.  this is a replacement for
  2301.     // loadDataScript() / downloadAndCacheScript()
  2302.     //
  2303.     SBgDlProcessState : function()
  2304.     {
  2305.         var timer = updater.MasterScript.CreateTimer("  Entering SBgDlProcessState()");
  2306.       var sm = updater.gStateMachine;
  2307.  
  2308.       try {
  2309.         var state = sm.state;
  2310.         var st_enum = sm.enumStates;
  2311.         
  2312.         //updater.console.println("= SBgDlProcessState =");
  2313.         //updater.MasterScript.DumpObject(sm.idleArgs, "idleArgs", true);
  2314.  
  2315.         // unpackage the args
  2316.         var loadScriptArgs = sm.idleArgs.loadScriptArgs;
  2317.         updater.MasterScript.assert(loadScriptArgs.constructor == Array, "loadScriptArgs not an Array!");
  2318.  
  2319.         // init idx
  2320.         if (! updater.MasterScript.PropertyIsDefined(sm, "scriptArgIdx") ) {
  2321.           sm.scriptArgIdx = 0;
  2322.           }
  2323.  
  2324.         // updater.console.println("scriptArgIdx = " + sm.scriptArgIdx);
  2325.         // updater.MasterScript.DumpArray(loadScriptArgs);
  2326.  
  2327.         var lsArgs = loadScriptArgs[sm.scriptArgIdx];
  2328.         
  2329.         // cannot check assert here since lsArgs MAYBE null for the last
  2330.         // element before proceeding to the StFinished state
  2331.         //updater.MasterScript.assert(lsArgs, "lsArgs is NULL");
  2332.         // updater.MasterScript.DumpObject(lsArgs, "lsArgs", true);
  2333.  
  2334.         var scriptURL = lsArgs? lsArgs["scriptURL"] : null;
  2335.         var serializationRoot = lsArgs ? lsArgs["serializationRoot"] : null;
  2336.         var scriptCacheName = lsArgs ? lsArgs["scriptCacheName"] : null;
  2337.         var callPoint = lsArgs ? lsArgs["callPoint"] : null;
  2338.         var dontMount = lsArgs ? lsArgs["dontMount"] : null;
  2339.  
  2340.         var suppressUI = sm.idleArgs["suppressUI"];
  2341.         var closeUI = sm.idleArgs["closeUI"];
  2342.  
  2343.         switch (state) {
  2344.           case st_enum.StInit : 
  2345.             try {
  2346.               updater.console.println("=== StInit ===");
  2347.               if (! scriptURL || scriptURL.length <=0 ) { 
  2348.                 sm.exception =  "InvalidScriptURL"; 
  2349.                 sm.state = sm.StException;
  2350.                 break;
  2351.                 }
  2352.               updater.console.println("  url = " + scriptURL);
  2353.               // setup private var in sm
  2354.               sm.cachedScriptObj = null;
  2355.               sm.cachedScriptObj = updater.MasterScript.GetCachedScriptObj(serializationRoot, scriptCacheName);
  2356.               
  2357.               sm.cachedScriptModDate = null;
  2358.               sm.cachedScriptModDate = updater.MasterScript.GetCachedScriptModDate(sm.cachedScriptObj);
  2359.               
  2360.               sm.state = sm.enumStates.StShowUI;
  2361.               }
  2362.             catch (e) {
  2363.               updater.console.println("Exception in StInit: " + e);
  2364.               sm.exception = e;
  2365.               sm.state = sm.StException;
  2366.               }
  2367.             break;
  2368.  
  2369.         case st_enum.StShowUI:
  2370.           try {
  2371.             updater.console.println("=== StShowUI ===");
  2372.             if (!suppressUI) {
  2373.               updater.app.showProgressDialog();
  2374.               }
  2375.             sm.uiCancelled = false;
  2376.             sm.state = sm.enumStates.StReadStart;
  2377.             }
  2378.           catch (e) {
  2379.               updater.console.println("Exception in StShowUI: " + e);
  2380.               sm.exception = e;
  2381.               sm.state = sm.StException;
  2382.             }
  2383.           break;
  2384.           
  2385.         case st_enum.StReadStart :
  2386.           try {
  2387.             updater.console.println("=== StReadStart ===");
  2388.             sm.response = null;
  2389.  
  2390.             if (sm.cachedScriptModDate) {
  2391.               updater.console.println(" calls updater.net.urlGetAsync() using if-mod-since");
  2392.               sm.urlMon = updater.net.urlGetAsync(scriptURL, sm.cachedScriptModDate.toUTCString());
  2393.               }
  2394.             else {
  2395.               updater.console.println(" calls updater.net.urlGetAsync()");
  2396.               sm.urlMon = updater.net.urlGetAsync(scriptURL);
  2397.               }
  2398.             sm.state = sm.enumStates.StProcessUI;
  2399.             }
  2400.           catch (e) {
  2401.             updater.console.println("Exception in StReadStart" + e);
  2402.             sm.exception = "URLGetException";
  2403.             sm.state = sm.enumStates.StException;
  2404.             }
  2405.           break;
  2406.  
  2407.         case st_enum.StProcessUI :
  2408.           try {
  2409.             updater.console.println("=== StProcessUI ===");
  2410.             // updater.app.processDialogEvent();
  2411.             sm.state = sm.enumStates.StUIWait; 
  2412.             }
  2413.           catch (e) {
  2414.               updater.console.println("Exception in StPocessUI: " + e);
  2415.               sm.exception = e;
  2416.               sm.state = sm.StException;            
  2417.             }
  2418.           break;
  2419.  
  2420.         case st_enum.StUIWait :
  2421.           try {
  2422.             updater.console.println("=== StUIWait ===");
  2423.             sm.uiCancelled = updater.app.isProgressDialogCancelled()
  2424.             sm.state = sm.enumStates.StReadWait; 
  2425.             }
  2426.           catch (e) {
  2427.               updater.console.println("Exception in StUIWait: " + e);
  2428.               sm.exception = e;
  2429.               sm.state = sm.StException;            
  2430.             }
  2431.           break;
  2432.               
  2433.         case st_enum.StReadWait :
  2434.           try {
  2435.             updater.console.println("=== StReadWait ===");
  2436.  
  2437.             if (sm.uiCancelled) {
  2438.               sm.urlMon.cancel();
  2439.               sm.exception = "DownloadCancelled";
  2440.               sm.state = sm.enumStates.StException;
  2441.               break;
  2442.               }
  2443.  
  2444.             if (sm.urlMon.done) {
  2445.               sm.state = st_enum.StReadDone;
  2446.               break;
  2447.               }
  2448.  
  2449.             sm.urlMon.wait();
  2450.  
  2451.             sm.state = st_enum.StProcessUI;
  2452.             }
  2453.           catch (e) {
  2454.             updater.console.println("Exception in StReadWait" + e);
  2455.             sm.exception = e;
  2456.             sm.state = sm.enumStates.StException;
  2457.             }
  2458.           break;
  2459.  
  2460.         case st_enum.StReadDone:
  2461.           try {
  2462.             updater.console.println("=== StReadDone ===");
  2463.  
  2464.             // should check again if ui is cancelled due to late click
  2465.             // latching
  2466.             if (updater.app.isProgressDialogCancelled()) {
  2467.               sm.exception = "DownloadCancelled";
  2468.               sm.state = sm.enumStates.StException;
  2469.               break;
  2470.               }
  2471.  
  2472.             if (! updater.MasterScript.PropertyIsDefined(sm, "scriptObjs")
  2473.                 || (sm.scriptObjs.constructor != Array) ) {
  2474.               sm.scriptObjs = new Array();
  2475.               }
  2476.  
  2477.             var idx = sm.scriptArgIdx;
  2478.  
  2479.             // acrobat can raise in urlMon.response if the download scripts
  2480.             // not signed correctly
  2481.             sm.scriptObjs[idx] = 
  2482.                 updater.MasterScript.GetAndCacheScriptObjFromResp(sm.cachedScriptObj, 
  2483.                    sm.urlMon.response, serializationRoot, scriptCacheName);
  2484.  
  2485.             // mount call point
  2486.             if (!dontMount) {
  2487.               updater[callPoint] = sm.scriptObjs[idx];
  2488.               }
  2489.               
  2490.             // initialize script obj
  2491.             if (updater.MasterScript.PropertyIsDefined(updater[callPoint], 
  2492.                                                        "Initialize")
  2493.                 &&
  2494.                 updater[callPoint]["Initialize"].constructor == Function) {
  2495.               updater[callPoint]["Initialize"]();
  2496.               }
  2497.  
  2498.             // done when all script in loadScriptArgs is iterated 
  2499.             sm.scriptArgIdx++;
  2500.             if (sm.scriptArgIdx < loadScriptArgs.length) {
  2501.               sm.state = st_enum.StInit;
  2502.             }
  2503.             else {
  2504.               if (closeUI) {
  2505.                 updater.app.hideProgressDialog();
  2506.                 }
  2507.               sm.state = st_enum.StFinished;
  2508.               }
  2509.             }
  2510.           catch (e) {
  2511.             updater.console.println("Exception in StReadDone : " + e);
  2512.             sm.exception = e;
  2513.             sm.state = sm.enumStates.StException;
  2514.             }
  2515.           break;
  2516.  
  2517.         case st_enum.StException:
  2518.           updater.console.println("=== StException ===");
  2519.           // always closes UI when exception happens
  2520.           updater.app.hideProgressDialog();
  2521.  
  2522.           var e = sm.exception;
  2523.           updater.console.println("Exception in " + sm.name + ": " + e);
  2524.  
  2525.           if (e == "URLGetException" || e == "URLContentNotFound" || e == "ServerError") {
  2526.             // These errors are probably network or server related.  don't
  2527.             // even need to bother user with the error.  just inform them no
  2528.             // update is available at this time
  2529.             var title = updater.app.getUpdaterString("uisJSNoUpdtAvailTitle");
  2530.             var errMsg = updater.app.getUpdaterString("uisJSNoUpdtAvailAtThisTimeText");
  2531.  
  2532.             if (! suppressUI) 
  2533.               updater.app.alert({nIcon:3, nType:0, cTitle:title, cMsg:errMsg});
  2534.             }
  2535.           else if (e == "NoDateHeader" || e == "BadData") {
  2536.             // probably should not pop dialog here since these are internal
  2537.             // errors from downloadAndCacheScript
  2538.             var title = updater.app.getUpdaterString("bsJSNoNetConnectTitle");
  2539.             var errMsg = updater.app.getUpdaterString("bsJSInternalErrorText");
  2540.             
  2541.             if (! suppressUI)
  2542.               updater.app.alert({nIcon:0, nType:0, cTitle:title, cMsg:errMsg});
  2543.             }
  2544.           else if (e == "DownloadCancelled" ) {
  2545.             updater.MasterScript.assert(false, "DownloadCancelled");
  2546.             updater.console.println("DownloadCancelled");
  2547.             // siliently swollow the exception if user cancelled out
  2548.             }
  2549.  
  2550.           sm.exception = "LoadScriptException";
  2551.           sm.state = st_enum.StFinished;
  2552.           break;
  2553.  
  2554.         case st_enum.StFinished:
  2555.           try {
  2556.             updater.console.println("=== StFinished ===");
  2557.             
  2558.             // should check again if ui is cancelled due to late click
  2559.             // latching
  2560.             if (!sm.uiCancelled && updater.app.isProgressDialogCancelled()) {
  2561.               updater.MasterScript.assert(false, "DownloadCancelled");
  2562.               updater.console.println("DownloadCancelled");
  2563.               sm.exception = "LoadScriptException";
  2564.               sm.state = sm.enumStates.StException;
  2565.               }
  2566.  
  2567.             // stop the state machine from advancing and release its lock
  2568.             // since we are done
  2569.             updater.app.clearInterval(sm.handle);
  2570.             sm.done = true;
  2571.             updater.gStateMachineLock = false;
  2572.           
  2573.             // call resume proc when done
  2574.             updater.MasterScript.assert(sm.resumeProc.constructor == Function, "resumeProc NOT a function");
  2575.             if (sm.resumeProc.constructor == Function) {
  2576.               sm.resumeProc(sm);
  2577.               }
  2578.             else {
  2579.               updater.console.println("sm.resumeProc not a function.  skip calling");
  2580.               }
  2581.             }
  2582.           catch (e) {
  2583.             updater.console.println("Exception in StFinished" + e);
  2584.             // close the UI 
  2585.             updater.app.hideProgressDialog();
  2586.             }
  2587.           break;
  2588.           
  2589.         default :
  2590.           updater.MasterScript.assert(false, "Shoule NOT reach default case - " + sm.name);
  2591.           throw "CannotHappen";
  2592.           break;
  2593.           }
  2594.         }
  2595.       catch (e) {
  2596.         sm.exception = e;
  2597.  
  2598.         updater.app.clearInterval(sm.handle);
  2599.         sm.done = true;
  2600.         updater.gStateMachineLock = false;
  2601.  
  2602.         updater.console.println("Exception in SBgDlProcessState: " + e);
  2603.       }
  2604.  
  2605.       updater.MasterScript.LogTimingInfo(timer, "  Exiting SBgDlProcessState()");
  2606.     },
  2607.  
  2608.     // 
  2609.     // Updater Script loading machinism
  2610.     // 
  2611.     // MasterScript: assumed always available (from bootstrap.js).  it
  2612.     // exports common functions and system functions to all other scripts.
  2613.     // It ONLY knows how to load DataScript.js.  Once DataScript is loaded,
  2614.     // MasterScript inquires DataScript about what other scripts DataScript
  2615.     // needs by calling DataScript.GetScriptDependencyList() and load all the
  2616.     // required scripts.  After each script is loaded, its Initialize()
  2617.     // function will be called if exists.
  2618.     //
  2619.     // DataScript: loaded only by MasterScript.  It has three piece of
  2620.     // information:
  2621.     //
  2622.     // 1) the available component data structure.  it contains all available
  2623.     // component for a given acrobat product configuration.
  2624.     //
  2625.     // 2) messages to be shown by the notification dialog
  2626.     //
  2627.     // 3) A function that returns a script depency list.  This allow future
  2628.     // expandability.  it initially contains only CodeScript and UIScript.
  2629.     //
  2630.     // DataScript Initialize() will have to check if the system has correct
  2631.     // version of MasterScript.  If not, it would call
  2632.     // LoadAndCacheScriptAsync() to get a new MasterScript.  A viewer restart
  2633.     // is required if new MasterScript is loaded.
  2634.     // 
  2635.     // CodeScript: Contains all procedures for doing Auto Update, Manual
  2636.     // Update, FincComponent, etc.
  2637.     //
  2638.     // UIScript: Contains all UI elements for Updater.
  2639.     //
  2640.     // Since MasterScript knows only DataScript, call-chaining is used so
  2641.     // that arbitrary scripts (potentially new scripts) can be used to
  2642.     // implement/replace Updater's functionality.  It works like this:
  2643.     // 
  2644.     // DataScript and the script contains the implementation of Updater's
  2645.     // functionality contains a common entry point, aptly named entryPoint().
  2646.     // it is called with an {} with "func", and "args" memebers.  DataScript
  2647.     // has the right to vector off the requests to the implementation script
  2648.     // (CodeScript) by simply calling entryPoint() with pass the arg along.
  2649.     // MasterScript.AutoUpdate() --> DataScript.entryPoint(arg)
  2650.     // --> CodeScript.entryPoint(arg) --> CodeScript.AutoUpdate(udArgs)
  2651.     // where arg is {func:AutoUpdate, arg:{udArgs}}
  2652.     // udArags is an {}
  2653.     //
  2654.     
  2655.     
  2656.     // 
  2657.     // LoadAndCacheScriptAsync
  2658.     // 
  2659.     // this is a single call for handling all the nasty details regarding
  2660.     // script downloading, mounting, caching, progress UI popping, etc
  2661.     // 
  2662.     // this is a non blocking call.  if suppressUI is true, no UI is shown by
  2663.     // default, the UI is not closed when operation is done unless closeUI is
  2664.     // true.  UI is always closed when exception happens
  2665.     // 
  2666.     // resumeProc will be called with resumeArgs when the script is
  2667.     // downloaded and mounted
  2668.     //
  2669.     // loadScriptArgs is an array of elements:
  2670.     // {
  2671.     //   "scriptURL" : this.getDSURL(),
  2672.     //   "serializationRoot" : updater.store.perUser,
  2673.     //   "scriptCacheName" : "cachedDataScript",
  2674.     //   "callPoint" : "DataScript"
  2675.     //   "dontMount" : false
  2676.     // }
  2677.     //
  2678.     // each element in the loadScriptArgs array will be processed sequentially
  2679.     //
  2680.     LoadAndCacheScriptAsync: function(loadScriptArgs,
  2681.                                       resumeProc, resumeArgs,
  2682.                                       suppressUI, closeUI)
  2683.     {
  2684.         var timer = updater.MasterScript.CreateTimer("  LoadAndCacheScriptAsync() entry");
  2685.       var idleProc =  "updater.MasterScript.SBgDlProcessState()";
  2686.       
  2687.       var idleArgs = { "loadScriptArgs" : loadScriptArgs,
  2688.                        "suppressUI" : suppressUI,
  2689.                        "closeUI" : closeUI };
  2690.                       
  2691.       this.SStartStateMachine(idleProc, idleArgs,
  2692.                               resumeProc, resumeArgs, 
  2693.                               "SBgDlProcessState", this.SBgDlStates);
  2694.         updater.MasterScript.LogTimingInfo(timer, "  LoadAndCacheScriptAsync() exit");
  2695.       return this.SStartStateMachine;
  2696.     },
  2697.  
  2698.     //
  2699.     // LoadScriptDepFinishProc is called after DataScripts AND its depending
  2700.     // scripts are all downloaded.  The update process continue by 
  2701.     //
  2702.     LoadScriptDepFinishProc: function(sm)
  2703.     {
  2704.       try {
  2705.         updater.console.println("LoadScriptDepFinishProc()"); 
  2706.         // something wrong in state machine, raise it
  2707.         if (sm.exception) { throw sm.exception };
  2708.  
  2709.         updater.MasterScript.assert(sm.resumeArgs["dsCallerResumeProc"], "dsCallerResumeProc undefined! ");
  2710.         
  2711.         updater.app.hideProgressDialog();
  2712.  
  2713.         var func = sm.resumeArgs["dsCallerResumeProc"];
  2714.         var args = sm.resumeArgs["dsCallerResumeArgs"];
  2715.         args.suppressUI = sm.idleArgs["suppressUI"];
  2716.         
  2717.         if (func.constructor == Function) {
  2718.           func(args);
  2719.           }
  2720.         }
  2721.       catch (e) {
  2722.         updater.console.println("Exception in LoadScriptDepFinishProc: " + e);
  2723.         }
  2724.     },
  2725.  
  2726.     //
  2727.     // LoadDataScriptFinishProc is called when DataScript is downloaded.  It
  2728.     // continue the script loading process by using DataScript's script
  2729.     // dependency list.
  2730.     //
  2731.     LoadDataScriptFinishProc: function(sm)
  2732.     {
  2733.       try {
  2734.         updater.console.println("LoadDataScriptFinishProc()"); 
  2735.  
  2736.         // something wrong in state machine, raise it
  2737.         if (sm.exception) { throw sm.exception };
  2738.  
  2739.         var depScriptsArgs = updater.DataScript.GetScriptDependency();
  2740.  
  2741.         // updater.MasterScript.DumpObject(depScriptsArgs,"depScriptsArgs", true);
  2742.  
  2743.         updater.MasterScript.assert(depScriptsArgs.constructor == Array);
  2744.  
  2745.         var suppressUI = sm.resumeArgs["dsCallerSuppressUI"];
  2746.         var closeUI = sm.resumeArgs["dsCallerCloseUI"];
  2747.  
  2748.         updater.MasterScript.LoadAndCacheScriptAsync(depScriptsArgs, 
  2749.                                                      updater.MasterScript.LoadScriptDepFinishProc,
  2750.                                                      sm.resumeArgs,
  2751.                                                      suppressUI, closeUI);
  2752.         }
  2753.       catch (e) {
  2754.         updater.console.println("Exception in LoadDataScriptFinishProc: " + e);
  2755.         }
  2756.     },
  2757.     
  2758.     // 
  2759.     // single call for loading DataScript and its depending scripts used by
  2760.     // AutoUpdateAsync, ManualUpdateAsync, FindComponentAsync, etc
  2761.     //
  2762.     LoadDataScriptAsync: function(resumeProc, resumeArgs, 
  2763.                                   suppressUI, closeUI)
  2764.     {
  2765.         var timer = updater.MasterScript.CreateTimer("  LoadDataScriptAsync");
  2766.       var loadScriptArgs = new Array();
  2767.       
  2768.       updater.MasterScript.LogTimingInfo(timer, "  start enuming resources to determine lang/tier");
  2769.  
  2770.       var dsLoadArgs = {
  2771.         "scriptURL" : this.getDSURL(),
  2772.         "serializationRoot" : updater.store.perUser,
  2773.         "scriptCacheName" : "cachedDataScript",
  2774.         "callPoint" : "DataScript"
  2775.         };
  2776.       
  2777.       updater.MasterScript.LogTimingInfo(timer, "  end enuming resources to determine lang/tier");
  2778.       
  2779.       loadScriptArgs[0] = dsLoadArgs;
  2780.  
  2781.       //
  2782.       // remember the orginal caller's resume proc and args so that after all
  2783.       // the DataScript depending are loaded, the update process know where
  2784.       // to continue.
  2785.       // 
  2786.       var dsFinishArg = {"dsCallerResumeProc": resumeProc,
  2787.                          "dsCallerResumeArgs" : resumeArgs,
  2788.                          "dsCallerSuppressUI" : suppressUI,
  2789.                          "dsCallerCloseUI" : closeUI};
  2790.  
  2791.       // before running resumeProc and resumeArgs, will call
  2792.       // LoadDataScriptFinishProc it load up all scripts DataScript requires
  2793.       this.LoadAndCacheScriptAsync(loadScriptArgs,
  2794.                                    this.LoadDataScriptFinishProc, dsFinishArg,
  2795.                                    suppressUI, closeUI);
  2796.         updater.MasterScript.LogTimingInfo(timer, "  Exiting LoadDataScriptAsync");
  2797.     },
  2798.     
  2799.     
  2800.     // Timer class
  2801.     
  2802.     nextTimerID: 0,
  2803.     
  2804.     TimerGetID: function()
  2805.     {
  2806.         return this.mID;
  2807.     },
  2808.     
  2809.     TimerReset: function()
  2810.     {
  2811.         this.mStartTicks = this.mElapsedTicks = this.Ticks();
  2812.     },
  2813.     
  2814.     TimerTicks: function()
  2815.     {
  2816.         var nowDate = new Date();
  2817.         var nowMS = nowDate.getTime();
  2818.         var nowTicks = (nowMS >> 4);
  2819.         return nowTicks;
  2820.     },
  2821.     
  2822.     TimerSetElapsed: function()
  2823.     {
  2824.         this.mElapsedTicks = this.Ticks();
  2825.     },
  2826.     
  2827.     TimerGetElapsedSinceStart: function()
  2828.     {
  2829.         return (this.Ticks() - this.mStartTicks);
  2830.     },
  2831.     
  2832.     TimerGetElapsedSinceLast: function()
  2833.     {
  2834.         return (this.Ticks() - this.mElapsedTicks);
  2835.     },
  2836.     
  2837.     Timer: function()
  2838.     {
  2839.         this.mID = updater.MasterScript.nextTimerID++;
  2840.         this.mStartTicks = 0;
  2841.         this.mElapsedTicks = 0;
  2842.         
  2843.         this.GetID = updater.MasterScript.TimerGetID;
  2844.         this.Reset = updater.MasterScript.TimerReset;
  2845.         this.Ticks = updater.MasterScript.TimerTicks;
  2846.         this.SetElapsed = updater.MasterScript.TimerSetElapsed;
  2847.         this.GetElapsedSinceStart = updater.MasterScript.TimerGetElapsedSinceStart;
  2848.         this.GetElapsedSinceLast = updater.MasterScript.TimerGetElapsedSinceLast;
  2849.         
  2850.         this.Reset();
  2851.     },
  2852.     
  2853.     CreateTimer: function(msg)
  2854.     {
  2855.         var timer = null;
  2856.         
  2857.         // avpref.get will raise if the reg key/value being accessed 
  2858.         // does not exist
  2859.         try
  2860.         {
  2861.             if (updater.avpref.get("Updater", "EnableTimingLog", 
  2862.                                 updater.avpref.type["Boolean"], false))
  2863.             {
  2864.                 timer = new updater.MasterScript.Timer();
  2865.                 var timerID = timer.GetID();
  2866.                 var msgStr = "Creating JS Timer " + timerID + "\n" + msg;
  2867.                 updater.console.println(msgStr);
  2868.             }
  2869.         }
  2870.         catch (e)
  2871.         {
  2872.             updater.console.println("Exception in updater.MasterScript.CreateTimer(): " + e);
  2873.         }
  2874.         
  2875.         return timer;
  2876.     },
  2877.     
  2878.     LogTimingInfo: function(timer, msg)
  2879.     {
  2880.         try
  2881.         {
  2882.             if ((timer != null) && (updater.avpref.get("Updater", "EnableTimingLog", 
  2883.                  updater.avpref.type["Boolean"], false)))
  2884.             {
  2885.                 var prefixStr = "";
  2886.  
  2887.                 if (msg.length > 0)
  2888.                 {
  2889.                     updater.console.println(msg);
  2890.                     prefixStr = "\t";
  2891.                 }
  2892.                 
  2893.                 var sinceStart = timer.GetElapsedSinceStart();
  2894.                 updater.console.println(prefixStr + "Ticks since start of JS Timer " + timer.GetID() + ": " + sinceStart);
  2895.                 var sinceLast = timer.GetElapsedSinceLast();
  2896.                 updater.console.println(prefixStr + "Ticks since last SetElapsed() of JS Timer " + timer.GetID() + ": " + sinceLast);
  2897.                 
  2898.                 timer.SetElapsed();
  2899.             }
  2900.         }
  2901.         catch (e)
  2902.         {
  2903.             updater.console.println("Exception in updater.MasterScript.LogTimingInfo(): " + e);
  2904.         }
  2905.     },
  2906.  
  2907.     //
  2908.     // Manual Update Procs
  2909.     //
  2910.     // this is called when DataScript.entryPoint() is done
  2911.     ManualUpdateCallBackProc: function(args)
  2912.     {
  2913.       try {
  2914.         updater.console.println("ManualUpdateCallBackProc()");
  2915.         var isMSUpdated = (updater.MasterScript.PropertyIsDefined(args, "exception") &&
  2916.                           args["exception"] == "MSUpdatedAbort");
  2917.         if (isMSUpdated)
  2918.         {
  2919.             updater.MasterScript.saveState();  // can raise 
  2920.         }
  2921.         else
  2922.         {
  2923.             updater.MasterScript.UpdateStore();
  2924.         }
  2925.       }
  2926.       catch (e) {
  2927.         updater.console.println("Exception in ManualUpdateCallBackProc: " + e);
  2928.       }
  2929.     },
  2930.  
  2931.     // this is called when DataScript and its depending scripts has been downloaded
  2932.     ManualUpdateFinishProc: function(args)
  2933.     {
  2934.       // call datascript main entry point
  2935.       try {
  2936.         updater.console.println("ManualUpdateFinishProc()"); 
  2937.  
  2938.         args.callBack = updater.MasterScript.ManualUpdateCallBackProc;
  2939.         args.callBackArgs = null;
  2940.         updater.DataScript.entryPoint(args);
  2941.       }
  2942.       catch (e) {
  2943.         updater.console.println("Exception in ManualUpdateFinishProc: " + e);
  2944.       }
  2945.     },
  2946.  
  2947.     ManualUpdateAsync: function()
  2948.     {
  2949.       try {
  2950.         updater.console.println("ManualUpdateAsync()"); 
  2951.         if ( ! this.init(false) ) return;
  2952.  
  2953.         updater.MasterScript.UpdateFromStore();
  2954.  
  2955.         updater.isAutoUpdate = false;
  2956.         updater.useSyncRead = false;
  2957.         var finishProcArgs = {func:"doUpdate", 
  2958.                               msUD:updater.MasterScript.msUDStateManualUD,
  2959.                               args:{isAutoUpdate:false, 
  2960.                                     isBkground:false}};
  2961.         this.LoadDataScriptAsync(this.ManualUpdateFinishProc, finishProcArgs);
  2962.         }
  2963.       catch (e) {
  2964.           updater.console.println("Exception in ManualUpdateAsync: " + e);
  2965.           return false;
  2966.       }
  2967.     },
  2968.  
  2969.  
  2970.     //
  2971.     // AutoUpdate and Check DLM Procs
  2972.     // 
  2973.  
  2974.     // this is called when DataScript.entryPoint() and AutoUpdate's
  2975.     // implemention is call and done
  2976.     AutoUpdateCallBackProc: function(args)
  2977.     {
  2978.       try {
  2979.         updater.console.println("AutoUpdateCallBackProc()"); 
  2980.         var isMSUpdated = (updater.MasterScript.PropertyIsDefined(args, "exception") &&
  2981.                           args["exception"] == "MSUpdatedAbort");
  2982.                           
  2983.         
  2984.         var updateTime = false;
  2985.             
  2986.         if (updater.MasterScript.PropertyIsDefined(args, "updateTime"))
  2987.         {
  2988.             updater.console.println("  updateTime = " + args["updateTime"]);
  2989.             updateTime = (args["updateTime"] == true && !isMSUpdated);
  2990.         }
  2991.         else
  2992.         {
  2993.             updateTime = !isMSUpdated;
  2994.         }
  2995.         
  2996.         if (updateTime)
  2997.         {
  2998.             updater.MasterScript.advanceNextCheckDate();
  2999.         }
  3000.         else if (!isMSUpdated)
  3001.         {
  3002.             updater.console.println("Background autoupdate -- skipping advanceNextCheckDate()");
  3003.         }
  3004.                   
  3005.         if ( ! isMSUpdated ) 
  3006.         {
  3007.             updater.MasterScript.popNotifications();
  3008.         }
  3009.         else
  3010.         {
  3011.             updater.console.println("MasterScript has been updated. skipping advanceNextCheckDate() and popNotifications()");
  3012.         }
  3013.         
  3014.         if (isMSUpdated)
  3015.         {
  3016.             updater.MasterScript.saveState();  // can raise 
  3017.         }
  3018.         else
  3019.         {
  3020.             updater.MasterScript.UpdateStore();
  3021.         }
  3022.       }
  3023.       catch (e) {
  3024.         updater.console.println("Exception in AutoUpdateCallBackProc: " + e);
  3025.       }
  3026.     },
  3027.  
  3028.     // this is called when DataScript has been downloaded
  3029.     AutoUpdateFinishProc: function(args)
  3030.     {
  3031.       // call datascript main entry point
  3032.       try {
  3033.         updater.console.println("AutoUpdateFinishProc()"); 
  3034.  
  3035.         args.callBack = updater.MasterScript.AutoUpdateCallBackProc;
  3036.         args.callBackArgs = {updateTime : args.updateTime};
  3037.         updater.DataScript.entryPoint(args);
  3038.       }
  3039.       catch (e) {
  3040.         updater.console.println("Exception in AutoUpdateFinishProc: " + e);
  3041.       }
  3042.     },
  3043.     
  3044.     CheckDLMStateCallBackProc: function(args)
  3045.     {
  3046.         updater.console.println("CheckDLMStateCallBackProc()");
  3047.         try
  3048.         {
  3049.             var isMSUpdated = (updater.MasterScript.PropertyIsDefined(args, "exception") &&
  3050.                           args["exception"] == "MSUpdatedAbort");
  3051.             if (isMSUpdated)
  3052.             {
  3053.                 updater.MasterScript.saveState();  // can raise 
  3054.             }
  3055.             else
  3056.             {
  3057.                 updater.MasterScript.UpdateStore();
  3058.             }
  3059.         }
  3060.         catch (e) 
  3061.         {
  3062.             updater.console.println("Exception in CheckDLMStateCallBackProc: " + e);
  3063.         }
  3064.     
  3065.     },
  3066.  
  3067.     CheckDLMStateFinishProc: function(args)
  3068.     {
  3069.       // call datascript main entry point
  3070.       try {
  3071.         updater.console.println("CheckDLMStateFinishProc()");
  3072.         // Calling updater.DataScript.entryPoint(args) could cause the MasterScript.js to get updated, so
  3073.         // you always need to provide a callbackproc to save the MasterScript.js to udstore.js
  3074.         args.callBack = updater.MasterScript.CheckDLMStateCallBackProc;
  3075.         args.callBackArgs = {};
  3076.         updater.DataScript.entryPoint(args);
  3077.         }
  3078.       catch (e) {
  3079.         updater.console.println("Exception in CheckDLMStateFinishProc: " + e);
  3080.         }
  3081.     },
  3082.  
  3083.     AutoUpdateAsync: function()
  3084.     {
  3085.         var timer = updater.MasterScript.CreateTimer("  AutoUpdateAsync() entry");
  3086.         
  3087.       try {
  3088.         updater.console.println("AutoUpdateAsync()"); 
  3089.  
  3090.         if ( ! this.init(true) ) return;
  3091.         
  3092.         // do a quick check before using CodeScript's CheckDLMState() which
  3093.         // has dialogs.
  3094.         var dlmState = updater.dlm.getState();
  3095.         updater.MasterScript.LogTimingInfo(timer, "  got aum state");
  3096.         updater.console.println("  updater.dlm.getState() returns " + dlmState);
  3097.         // DLM not running.  rdy to accept transaction
  3098.         // quickly return
  3099.         if (dlmState != 0) { 
  3100.           // DLM has pending stuff
  3101.           // ok.  now we must do some UI since there are pending updates
  3102.           // calls into CodeScript's CheckDLMState()
  3103.           
  3104.           if (! updater.MasterScript.checkNetConnection(true) ) {
  3105.             // if no net, try if all scripts are cached already.
  3106.             var hasAllScripts = updater.MasterScript.getAllScriptsFromStore();
  3107.             if (hasAllScripts) {
  3108.               updater.DataScript.entryPoint({func:"CheckDLMState", args:{showResumeDlg:true, doResume:true}}); 
  3109.               }
  3110.             }
  3111.           else {
  3112.             // has net connection            
  3113.             // finishProcArgs is the args for calling DataScript.entryPoint(args)
  3114.             var finishProcArgs = {func:"CheckDLMState",
  3115.                                   msUD:updater.MasterScript.msUDStateAutoUD, 
  3116.                                   args:{showResumeDlg:true, doResume:true}};
  3117.             this.LoadDataScriptAsync(this.CheckDLMStateFinishProc, finishProcArgs, true);
  3118.             }
  3119.           return;
  3120.           }
  3121.         else {
  3122.             // continue AutoUpdate
  3123.             updater.MasterScript.UpdateFromStore();
  3124.             updater.MasterScript.LogTimingInfo(timer, "  loaded udstore.js");
  3125.  
  3126.             // check if pref is set the monthly
  3127.             // background: 2
  3128.             // monthly: 1
  3129.             // manually: 0
  3130.             var freq = updater.app.getUpdateFrequency();
  3131.             updater.console.println("  freq = " + freq);
  3132.  
  3133.             // If doing foreground/notification auto update 
  3134.             // do so when it is time.  If doing background updating, 
  3135.             // we always perform an autoupdate.
  3136.             
  3137.             // Always check the update time -- this will advance the check time
  3138.             // after downloading DS.js if MS.js wasn't updated.
  3139.             var bUpdateTime = this.isTimeToUpdate();
  3140.             if (bUpdateTime && (freq == 2 || freq == 1))
  3141.             {
  3142.                 updater.console.println("Loading DataScript and performing update...");
  3143.                 // silently returns if autoupdate and no net
  3144.                 if (! updater.MasterScript.checkNetConnection(true) )
  3145.                 {
  3146.                     return false;
  3147.                 }
  3148.                 updater.MasterScript.LogTimingInfo(timer, "  checked net connection");
  3149.                 
  3150.                 updater.isAutoUpdate = true;
  3151.                 updater.useSyncRead = true;
  3152.  
  3153.                 // finishProcArgs is the args for calling DataScript.entryPoint(args)            
  3154.                 var finishProcArgs = {func:"doUpdate", 
  3155.                                       msUD:updater.MasterScript.msUDStateAutoUD,
  3156.                                       args:{isAutoUpdate:true, 
  3157.                                             isBkground:(freq == 2)},
  3158.  
  3159.                                       updateTime: true};
  3160.                 this.LoadDataScriptAsync(this.AutoUpdateFinishProc, finishProcArgs, true);
  3161.                 updater.MasterScript.LogTimingInfo(timer, "  set up loaddatascript idle proc");
  3162.             }
  3163.             else {
  3164.                 // Manual Update
  3165.                 // pop new notifications. calls only finish auto-update check, not
  3166.                 // manual check
  3167.                 this.popNotifications();
  3168.                 updater.MasterScript.UpdateStore();
  3169.             }
  3170.           }
  3171.         }
  3172.       catch (e) {
  3173.         updater.console.println("Exception in AutoUpdateAsync: " + e);
  3174.         return false;
  3175.         }
  3176.     },
  3177.  
  3178.  
  3179.     //
  3180.     // FindComponent Procs
  3181.     // 
  3182.     // this is called when DataScript.entryPoint() is done
  3183.     FindComponentCallBackProc: function(args)
  3184.     {
  3185.       try {
  3186.         updater.console.println("FindComponentCallBackProc()"); 
  3187.  
  3188.         var ret = args["returnVal"];
  3189.         updater.console.println("ComponentFound = " + ret); 
  3190.         var isMSUpdated = (updater.MasterScript.PropertyIsDefined(args, "exception") &&
  3191.                           args["exception"] == "MSUpdatedAbort");
  3192.         if (isMSUpdated)
  3193.         {
  3194.             updater.MasterScript.saveState();  // can raise 
  3195.         }
  3196.         else
  3197.         {
  3198.             updater.MasterScript.UpdateStore();
  3199.         }
  3200.       }
  3201.       catch (e) {
  3202.         updater.console.println("Exception in FindComponentCallBackProc: " + e);
  3203.       }
  3204.     },
  3205.  
  3206.     // this is called when DataScript has been downloaded
  3207.     FindComponentFinishProc: function(args)
  3208.     {
  3209.       // call datascript main entry point
  3210.       try {
  3211.         updater.console.println("FindComponentFinishProc()"); 
  3212.  
  3213.         args.callBack = updater.MasterScript.FindComponentCallBackProc;
  3214.         args.callBackArgs = null;
  3215.         updater.DataScript.entryPoint(args);
  3216.       }
  3217.       catch (e) {
  3218.         updater.console.println("Exception in FindComponentFinishProc: " + e);
  3219.       }
  3220.     },
  3221.  
  3222.     FindComponentAsync: function(type, name, desc, ver, params, silent)
  3223.     {
  3224.       try {
  3225.         updater.console.println("FindComponentAsync()"); 
  3226.  
  3227.         if ( ! this.init() ) return;
  3228.  
  3229.         updater.MasterScript.UpdateFromStore();
  3230.  
  3231.         var hasNet = updater.net.isConnected();
  3232.         var wellKnown = false;
  3233.         var wellKnownDesc = "";
  3234.  
  3235.         if ( !desc || desc.length == 0 ) {
  3236.           // no desc given by caller.  try lookup well known component
  3237.           // description
  3238.           var knownDesc = this.lookUpWellKnownCompDesc(type, name);
  3239.           if (knownDesc && knownDesc.length > 0) {
  3240.             wellKnown = true;
  3241.             wellKnownDesc = knownDesc;
  3242.             }
  3243.           else {
  3244.             wellKnown = false;
  3245.             wellKnownDesc = type + "/" + name;
  3246.             if (ver) wellKnownDesc = wellKnownDesc + ":" + ver;
  3247.             }
  3248.           }
  3249.  
  3250.         updater.console.println("  wellKnown = " + wellKnown);
  3251.         updater.console.println("  wellKnownDesc = " + wellKnownDesc);
  3252.         
  3253.         // if no net, prompt user if connecting to net is ok
  3254.         if (! hasNet) {
  3255.           updater.console.println("  no Internet connection");
  3256.           var cont;
  3257.           if (wellKnown) {
  3258.             cont = this.showMissingCompDialog("\"" + wellKnownDesc + "\"");
  3259.             }
  3260.           else {
  3261.             cont = this.showMissingCompDialog();
  3262.             }
  3263.           // no = 3,  yes =4
  3264.           if (cont == 3) return false;
  3265.           }
  3266.           
  3267.           updater.console.println("  Internet connection exists");
  3268.           
  3269.         
  3270.         // user wants to continue.  forward request to CodeScript via DataScript
  3271.         // download the datascript (may need to connect to net)
  3272.  
  3273.  
  3274.         var finishProcArgs = {func:"findComponent", 
  3275.                               msUD:updater.MasterScript.msUDStateFindComp,
  3276.                               args:{type:type, 
  3277.                                     name:name, 
  3278.                                     desc:desc, 
  3279.                                     ver:ver, 
  3280.                                     params:params, 
  3281.                                     silent:silent}};
  3282.         this.LoadDataScriptAsync(this.FindComponentFinishProc, finishProcArgs, silent);
  3283.         return true;
  3284.         }
  3285.       catch (e) {
  3286.           updater.console.println("Exception in FindComponentAsync: " + e);
  3287.           return false;
  3288.       }
  3289.     },
  3290.  
  3291.     //
  3292.     // CheckForUpdate Procs
  3293.     // 
  3294.     // this is called when DataScript.entryPoint() is done
  3295.     
  3296.     // These must be in sync with enum in UpdaterExpT.h
  3297.     UDCheckUpdate_NotChecked: 0,
  3298.     UDCheckUpdate_NetFound: 1,
  3299.     UDCheckUpdate_NetNotFound: 2,
  3300.     UDCheckUpdate_NoNetFound: 3,
  3301.     UDCheckUpdate_NoNetNotFound: 4,
  3302.     
  3303.     CheckForUpdateCallBackProc: function(args)
  3304.     {
  3305.         try 
  3306.         {
  3307.             updater.console.println("CheckForUpdateCallBackProc()"); 
  3308.  
  3309.             var ret = args["returnVal"];
  3310.             updater.console.println("  Component found = " + ret); 
  3311.             var isMSUpdated = (updater.MasterScript.PropertyIsDefined(args, "exception") &&
  3312.                           args["exception"] == "MSUpdatedAbort");
  3313.             if (isMSUpdated)
  3314.             {
  3315.                 updater.MasterScript.saveState();  // can raise 
  3316.             }
  3317.             else
  3318.             {
  3319.                 updater.MasterScript.UpdateStore();
  3320.             }
  3321.         }
  3322.         catch (e) 
  3323.         {
  3324.             updater.console.println("Exception in CheckForUpdateCallBackProc(): " + e);
  3325.         }
  3326.     },
  3327.  
  3328.     CheckForUpdateFinishProc: function(args)
  3329.     {
  3330.         // call datascript main entry point
  3331.         try 
  3332.         {
  3333.             updater.console.println("CheckForUpdateFinishProc()"); 
  3334.  
  3335.             args.callBack = updater.MasterScript.CheckForUpdateCallBackProc;
  3336.             args.callBackArgs = null;
  3337.             updater.DataScript.entryPoint(args);
  3338.         }
  3339.         catch (e) 
  3340.         {
  3341.             updater.console.println("Exception in CheckForUpdateFinishProc(): " + e);
  3342.         }
  3343.     },
  3344.     
  3345.     CallCheckedUpdateCB: function()
  3346.     {
  3347.         updater.console.println("CallCheckedUpdateCB()");
  3348.         var cuData = updater.gCheckedUpdateData;
  3349.         
  3350.         if (cuData.hasScripts)
  3351.         {
  3352.             updater.DataScript.entryPoint(cuData.funcObj);
  3353.         }
  3354.         else
  3355.         {
  3356.             updater.app.execCheckedUpdateCallback(updater.MasterScript.UDCheckUpdate_NotChecked);
  3357.         }
  3358.         
  3359.         updater.app.clearInterval(cuData.handle);
  3360.         cuData.lock = false;
  3361.     },
  3362.  
  3363.     CheckForUpdateAsync: function(type, name, msg, ver, params, silent)
  3364.     {
  3365.         try
  3366.         {
  3367.             updater.console.println("CheckForUpdateAsync()"); 
  3368.  
  3369.             if (!this.init())
  3370.             {
  3371.                 return false;
  3372.             }
  3373.  
  3374.             updater.MasterScript.UpdateFromStore();
  3375.  
  3376.             var hasNet = updater.net.isConnected();
  3377.  
  3378.             // If no net, check to see if has cached script files.
  3379.             if (!hasNet) 
  3380.             {
  3381.                 
  3382.                 if (this.PropertyIsDefined(updater, "gCheckedUpdateData") &&
  3383.                     updater.gCheckedUpdateData.lock == true) 
  3384.                 {
  3385.                     updater.console.println("updater.gCheckedUpdateData is locked");
  3386.                     return false;
  3387.                 }
  3388.                 
  3389.                 updater.gCheckedUpdateData = new Object();
  3390.                 var cuData = updater.gCheckedUpdateData;
  3391.                 var checkUpdateDelayedIdleProc = "";
  3392.                 
  3393.                 cuData.funcObj = {func:"checkForUpdate", 
  3394.                         args:{type:type, name:name, msg:msg, ver:ver, params:params, hasNet:false}};
  3395.                                         
  3396.                 cuData.hasScripts = updater.MasterScript.getAllScriptsFromStore();
  3397.                 
  3398.                 checkUpdateDelayedIdleProc = "updater.MasterScript.CallCheckedUpdateCB()";
  3399.                 cuData.handle = updater.app.setInterval(checkUpdateDelayedIdleProc, 60);
  3400.                 cuData.lock = true;
  3401.                 return true;
  3402.             }
  3403.         
  3404.             // Forward request to CodeScript via DataScript download the datascript (may need to connect to net)
  3405.  
  3406.             var finishProcArgs = {func:"checkForUpdate", 
  3407.                                   msUD:updater.MasterScript.msUDStateCheckForUD,
  3408.                                   args:{type:type, 
  3409.                                         name:name, 
  3410.                                         msg:msg, 
  3411.                                         ver:ver, 
  3412.                                         params:params, 
  3413.                                         hasNet:true}};
  3414.             this.LoadDataScriptAsync(this.CheckForUpdateFinishProc, finishProcArgs, silent);
  3415.             return true;
  3416.         }
  3417.         catch (e)
  3418.         {
  3419.             updater.console.println("Exception in CheckForUpdateAsync(): " + e);
  3420.             return false;
  3421.         }
  3422.     },
  3423.     
  3424.     // ********************* //
  3425.     // ********************* //
  3426.     //      NewPDFCheck      //
  3427.     // ********************* //
  3428.     // ********************* //
  3429.     
  3430.     // This function is called when DataScript.entryPoint() has had a chance to update updater.MasterScript.
  3431.     NewPDFCheckCallBackProc: function(args)
  3432.     {
  3433.       try {
  3434.         updater.console.println("NewPDFCheckCallBackProc()"); 
  3435.  
  3436.         var ret = args["returnVal"];
  3437.         var isMSUpdated = (updater.MasterScript.PropertyIsDefined(args, "exception") &&
  3438.                           args["exception"] == "MSUpdatedAbort");
  3439.         if (isMSUpdated)
  3440.         {
  3441.             updater.MasterScript.saveState();  // can raise 
  3442.         }
  3443.         else
  3444.         {
  3445.             updater.MasterScript.UpdateStore();
  3446.         }
  3447.       }
  3448.       catch (e) {
  3449.         updater.console.println("Exception in NewPDFCheckCallBackProc: " + e);
  3450.       }
  3451.     },
  3452.     
  3453.     // When all the scripts have been downloaded, this function gets called to call the DataScript main entry point.
  3454.     // If the MasterScript.js has been updated, the entry point will re-load updater.MasterScript.  The entry point
  3455.     // will then call updater.MasterScript.NewPDFCheckCallBackProc() for post MS update processing.
  3456.     NewPDFCheckFinishProc: function(args)
  3457.     {
  3458.         try 
  3459.         {
  3460.             updater.console.println("NewPDFCheckFinishProc()"); 
  3461.  
  3462.             args.callBack = updater.MasterScript.NewPDFCheckCallBackProc;
  3463.             args.callBackArgs = null;
  3464.             updater.DataScript.entryPoint(args);
  3465.         }
  3466.         catch (e) 
  3467.         {
  3468.             updater.console.println("Exception in CheckForUpdateFinishProc(): " + e);
  3469.         }
  3470.     },
  3471.     
  3472.     NewPDFCheckAsync: function(fileSizeHi, fileSizeLo, headBuf, headSize, tailBuf, tailSize, silent)
  3473.     {
  3474.         var ret = false;
  3475.         
  3476.         try
  3477.         {
  3478.             updater.console.println("NewPDFCheckAsync()");
  3479.  
  3480.             if (this.init())
  3481.             {
  3482.                 updater.MasterScript.UpdateFromStore();
  3483.                 var fileSize = (fileSizeHi << 32) + fileSizeLo;
  3484.  
  3485.                 if (false)
  3486.                 {
  3487.                     var finishProcArgs = {func:"newPDFCheck", 
  3488.                                         msUD:updater.MasterScript.msUDStateNewPDF,
  3489.                                         args:{fileSizeHi:fileSizeHi, 
  3490.                                               fileSizeLo:fileSizeLo,
  3491.                                               headBuf:headBuf, 
  3492.                                               headSize:headSize, 
  3493.                                               tailBuf:tailBuf, 
  3494.                                               tailSize:tailSize, 
  3495.                                               silent:silent}};
  3496.  
  3497.                     updater.MasterScript.LoadDataScriptAsync(this.NewPDFCheckFinishProc, finishProcArgs, silent);
  3498.                     ret = true;    
  3499.                 }
  3500.             }
  3501.         }
  3502.         catch (e)
  3503.         {
  3504.             updater.console.println("Exception in NewPDFCheckAsync(): " + e);
  3505.             ret = false;
  3506.         }
  3507.         
  3508.         return ret;
  3509.     },
  3510.  
  3511.     __ENDER__:"END"
  3512. };
  3513.  
  3514. ScriptObj;
  3515. // ==========================================================================
  3516. //    Module: StartUp.js
  3517. // ==========================================================================
  3518. //    JS functionality for Updater
  3519. // ==========================================================================
  3520. //  The Software, including this file, is subject to the End User License 
  3521. //  Agreement.
  3522. //  Copyright (c) 2003-2004, Adobe Systems Incorporated, All Rights Reserved.
  3523. // ==========================================================================
  3524. //
  3525. // StartUp.js
  3526. // 
  3527. // 
  3528. // the sole purpose of bootstrap script is to load up the masterscript and
  3529. // make sure it exists in Updater JS runtime (ie: defines
  3530. // updater.MasterScript).  it must also define a updater.scriptRootURL which
  3531. // can be used to defer the location of MasterScript on the server.
  3532. //
  3533. // during developement, the MasterScript is always loaded from a server by
  3534. // doing urlGet().  For release, there should be a presisted MasterScript in
  3535. // user's dir and the bootstrap script should load up the presist file and
  3536. // bring the cached MasterScript back to life.
  3537. //
  3538. // 
  3539. // Here is how MasterScript would be loaded up: 
  3540. // 
  3541. // 1) First check if an presisted version in updater.store is available.  If
  3542. // so, check its version againt updater.MasterScript( if it is even defined
  3543. // in the runtime probably because of bootstrap.js evaluation)
  3544. //
  3545. // Then set updater.MasterScript to the newer version.  This allow us to
  3546. // update and override MasterScript later on.
  3547. //
  3548. // 2) if NOT, use darn simple urlGet() to fetch it from
  3549. // updater.masterScriptURL the newly fetched script will be presisted so that
  3550. // it doesn't need to be refetch next time
  3551. // 
  3552. //
  3553. // updater.bootStrapped is a globle which C++ code can check if bootstrapping
  3554. // has happened.  it is for optimization so that bootstrip.js will only be
  3555. // opened and eval'ed once per app launch.
  3556. //
  3557. // updater.scriptRootURL is the base of where all scripts will live on server
  3558. //
  3559.  
  3560. updater.scriptRootURL = "http://update.adobe.com/pub/adobe/acrobat/js/7x/";
  3561.  
  3562. // updater.bootStrapped = false;
  3563.  
  3564. // Code for dumping all objects in the global space (except the app obj).
  3565. // It dumps all objs before update code has modified the initial state of the globals.
  3566. // Set the guard to true to use this code.
  3567. // Places a menu item in "Tools" for dumping the objects to udlog.txt also.
  3568. if (false)
  3569. {
  3570.     var DumpObject =
  3571.     function (obj, str, vals)
  3572.     {
  3573.         if (! str ) str = "";
  3574.         else str = str + ".";
  3575.           
  3576.         var pStr = str + "(" + obj + ") [" + typeof(obj) + "]";
  3577.         updater.console.println(pStr);
  3578.         pStr = "";
  3579.           
  3580.         for (var p in obj) {
  3581.             // Skip app global object since it causes all kinds of problems and it is not relevant.
  3582.             if (str == "this." && p == "app")
  3583.             {
  3584.                 continue;
  3585.             }
  3586.             
  3587.             pStr = str + p;
  3588.             
  3589.             if (p != "fromPDFConverters")
  3590.             {
  3591.                 var prop = obj[p];
  3592.  
  3593.                 if (prop != null && typeof(prop) == "object")
  3594.                 {
  3595.                     //updater.console.println("dumping obj " + p);
  3596.                     this.DumpObject(prop, pStr, true);
  3597.                 }
  3598.                 else
  3599.                 {
  3600.                     pStr += ( vals ? ": " + obj[p] : "");
  3601.                     updater.console.println(pStr);
  3602.                     pStr = "";
  3603.  
  3604.                 }
  3605.             }
  3606.         }
  3607.     }
  3608.  
  3609.     var DumpGlobals =
  3610.     function()
  3611.     {
  3612.         updater.console.println("===DUMPING ALL GLOBAL OBJS===");
  3613.         this.DumpObject(this, "this", true);
  3614.         updater.console.println("===END DUMPING ALL GLOBAL OBJS===");
  3615.     }
  3616.  
  3617.     if (!updater.dumped)
  3618.     {
  3619.     /*
  3620.     Not working anymore -- do it manually.
  3621.         app.addMenuItem({ cName: "dump globals", 
  3622.             cParent: "Tools",
  3623.             cExec: "this.DumpGlobals();", 
  3624.             cEnable: "true",
  3625.             nPos: 0});
  3626.     */
  3627.  
  3628.         this.DumpGlobals();
  3629.         updater.dumped = true;
  3630.     }
  3631. }
  3632.  
  3633. var StartUp = function(useESDUpdate)
  3634. {
  3635. if (! updater.bootStrapped) {
  3636.  
  3637.   try {
  3638.     updater.console.println("===== Loading bootstrap.js =====");
  3639.  
  3640.     // Since MasterScript WILL be prepended this file to form bootstrap.js, need
  3641.     // to check if ScriptObj exists and and pick it up as MasterScript
  3642.     if (typeof(ScriptObj) != "undefined") {
  3643.       updater.console.println("  picked up default MasterScript from bootstrap.js");
  3644.       updater.MasterScript = ScriptObj;
  3645.     }
  3646.  
  3647.     // overrideable scriptRootURL by Pref
  3648.     // updater.avpref can raise if the pref section/key not defined
  3649.     try {
  3650.       updater.scriptRootURL = updater.avpref.get("Updater", 
  3651.                                                  "ScriptRootURL", 
  3652.                                                  updater.avpref.type["String"], 
  3653.                                                  updater.scriptRootURL);
  3654.       updater.console.println("  overriding scriptRootURL from pref");
  3655.     } catch (e) {}  // safely ignore the raise by avpref 
  3656.  
  3657.     updater.console.println("  updater.scriptRootURL = " + updater.scriptRootURL);
  3658.  
  3659.     // first check if there is a presisted version (the following code has
  3660.     // CANNOT assume existence of MasterScripts and its friends of utilities
  3661.     // functions)
  3662.  
  3663.     try {
  3664.       updater.store.load();
  3665.       }
  3666.     catch (e) {
  3667.       updater.console.println("Exception in trying to do updater.store.load(): " + e);
  3668.       updater.console.println("  --> skip loading store");
  3669.       }
  3670.  
  3671.     var cachedMSVersion;
  3672.     var cachedMSName = "cachedMasterScript";
  3673.     cachedMSName = cachedMSName + "_" + updater.app.viewerType + "_" + updater.app.language;
  3674.     var curRunTimeMSVersion;
  3675.  
  3676.     var gotMasterScript = false;
  3677.  
  3678.     
  3679.     // version checking 
  3680.  
  3681.     // finding out cached MasterScript version
  3682.     if ( typeof(updater.store.perUser[cachedMSName]) != "undefined" &&
  3683.          typeof(updater.store.perUser[cachedMSName]["scriptObj"]) != "undefined" )
  3684.       {
  3685.       cachedMSVersion = updater.store.perUser[cachedMSName].scriptObj.version + 0.0;
  3686.       updater.console.println(" checking cachedMSVersion = " + cachedMSVersion);
  3687.       }
  3688.     else {
  3689.       cachedMSVersion = 0.0;
  3690.       }
  3691.  
  3692.     // finding out current MasterScript version
  3693.     if ( (typeof(updater["MasterScript"]) != "undefined" ) &&
  3694.          (typeof(updater.MasterScript["version"]) != "undefined") ) 
  3695.       {
  3696.       curRunTimeMSVersion = updater.MasterScript.version + 0.0;
  3697.       updater.console.println(" checking curRunTimeMSVersion = " + curRunTimeMSVersion);
  3698.       }
  3699.     else {
  3700.       curRunTimeMSVersion = 0.0;
  3701.       }
  3702.  
  3703.     if ( (curRunTimeMSVersion != 0) && (curRunTimeMSVersion > cachedMSVersion) ) {
  3704.       updater.console.println("--> Using MasterScript from current runtime.  version = " + curRunTimeMSVersion);
  3705.       gotMasterScript = true;
  3706.       }
  3707.  
  3708.     // MUST use >= to compare cached verion with the current one in runtime
  3709.     // since current one in runtime may well be the cached one when bootstrip
  3710.     // is eval the second time
  3711.     if ( !gotMasterScript &&
  3712.          (cachedMSVersion != 0) && (cachedMSVersion >= curRunTimeMSVersion) ) {
  3713.       updater.MasterScript = updater.store.perUser[cachedMSName].scriptObj;
  3714.       updater.console.println("--> Using MasterScript from cache.  version = " + cachedMSVersion);
  3715.       gotMasterScript = true;
  3716.       }
  3717.  
  3718.     if (!gotMasterScript) {
  3719.       // no existing MasterScript....do a urlGet();
  3720.       // first check if there is net connection
  3721.       var hasNet; 
  3722.       if ( typeof(updater.net["isConnected"]) != "undefined") 
  3723.       {
  3724.         hasNet = updater.net.isConnected();
  3725.       }
  3726.       else if (useESDUpdate)
  3727.       {
  3728.         hasNet = updater.dlm.hasNetAccess();
  3729.       }
  3730.       else
  3731.       {
  3732.         hasNet = false;
  3733.       }
  3734.       
  3735.       if (! hasNet) {
  3736.         // should use UIScript's showErrorDialog() when UIScript is presisted.
  3737.         // for now just do app.alert.
  3738.         var title = updater.app.getUpdaterString("bsJSNoNetConnectTitle");
  3739.         var errMsg = updater.app.getUpdaterString("bsJSNoNetConnectText");
  3740.         updater.app.alert({nIcon:0, nType:0, cTitle:title, cMsg:errMsg});
  3741.         }
  3742.       else {
  3743.         updater.console.println("  fetching MasterScript with urlGet()");
  3744.  
  3745.         // should add prod config into creating the URL later
  3746.         var masterScriptURL = updater.scriptRootURL + "MasterScript.js";
  3747.  
  3748.         var resp = updater.net.urlGet(masterScriptURL);
  3749.  
  3750.         updater.console.println("  eval MasterScript");
  3751.         var newScriptObj = eval( resp.Content );
  3752.         updater.console.println("  eval MasterScript doone");
  3753.         if ( newScriptObj == null ) {
  3754.           updater.console.println("  something wrong while eval resp.Content.  throws!");
  3755.           throw "badData";
  3756.           }
  3757.         updater.MasterScript = newScriptObj;
  3758.         
  3759.         updater.console.println("  saving MasterScript");
  3760.         // can null be used for cachedDate?
  3761.         updater.store.perUser[cachedMSName] = { cachedDate : null,
  3762.                                                 scriptObj : newScriptObj };
  3763.  
  3764.         // save user store
  3765.         try {
  3766.           updater.store.save();
  3767.           }
  3768.         catch (e) {
  3769.           updater.console.println("Exception in trying to updater.store.save(): " + e);
  3770.           throw new Error("SaveStateException");
  3771.           }
  3772.         
  3773.         gotMasterScript = true;
  3774.         }
  3775.       }
  3776.  
  3777.     updater.bootStrapped = gotMasterScript;
  3778.     
  3779.     updater.console.println("===== bootstrap.js done =====");
  3780.     }
  3781.   catch (e) {
  3782.     updater.console.println("  Exception during bootstrap - " + e);
  3783.     }
  3784. }
  3785. else {
  3786.   updater.console.println("===== bootstrap.js already loaded =====");
  3787. }
  3788.  
  3789. return updater.bootStrapped;
  3790. }
  3791.